/* ============================================================
   Blackjack - Dark Casino Theme
   Portrait-first mobile (390x844 base)
   ============================================================ */

/* ----- Font ----- */
@font-face {
  font-family: 'GameFont';
  src: url('../fonts/font.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

/* ----- Reset & Base ----- */
*, *::before, *::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  background-color: #1a1a2e;
  font-family: 'GameFont', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  color: #ffffff;
  overflow: hidden;
  width: 100vw;
  height: 100vh;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

/* ----- Screen System ----- */
.screen {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  z-index: 1;
}

.screen.active {
  display: flex;
}

/* ============================================================
   LOADING SCREEN
   ============================================================ */
#loading-screen {
  background: linear-gradient(180deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
}

.loading-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  padding: 20px;
}

.mascot-container {
  width: 180px;
  height: 180px;
  border-radius: 50%;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.05);
  border: 3px solid rgba(212, 175, 55, 0.4);
  animation: pulse 1.5s ease-in-out infinite;
}

.mascot-image {
  width: 256px;
  height: 256px;
  background-image: url('../images/buddy-lsheet0.webp');
  background-position: 0 0;
  background-size: auto;
  background-repeat: no-repeat;
  transform: scale(0.703125);
  transform-origin: top left;
}

.loading-text {
  font-size: 22px;
  color: #d4af37;
  letter-spacing: 3px;
  text-transform: uppercase;
  animation: pulse 1.5s ease-in-out infinite;
  margin: 0;
}

.loading-bar-container {
  width: 260px;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  overflow: hidden;
}

.loading-bar {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #d4af37, #f5e6a3, #d4af37);
  border-radius: 3px;
  transition: width 0.3s ease;
  background-size: 200% 100%;
  animation: loading-shimmer 1.5s ease-in-out infinite;
}

@keyframes loading-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ============================================================
   LOBBY SCREEN
   ============================================================ */
#lobby-screen {
  background: linear-gradient(180deg, #1a1a2e 0%, #16213e 100%);
  overflow-y: auto;
  overflow-x: hidden;
  align-items: flex-start;
  justify-content: flex-start;
}

.lobby-wrapper {
  width: 100%;
  max-width: 500px;
  margin: 0 auto;
  padding-bottom: 40px;
}

/* -- Lobby Top Bar -- */
.lobby-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  background: #2d2d4a;
  border-bottom: 1px solid rgba(212, 175, 55, 0.2);
  position: sticky;
  top: 0;
  z-index: 10;
}

.lobby-balance {
  display: flex;
  flex-direction: column;
}

.balance-label {
  font-size: 10px;
  color: #8888aa;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.balance-amount {
  font-size: 20px;
  color: #d4af37;
  font-weight: bold;
}

.lobby-player-name {
  font-size: 16px;
  color: #ccccdd;
  padding: 6px 14px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

/* -- Lobby Title -- */
.lobby-title {
  text-align: center;
  font-size: 20px;
  color: #d4af37;
  margin: 24px 0 16px;
  letter-spacing: 2px;
  text-transform: uppercase;
}

/* -- Stake Grid -- */
.stake-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  padding: 0 20px;
}

.stake-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  padding: 20px 12px;
  background: linear-gradient(135deg, #2d2d4a 0%, #1e1e36 100%);
  border: 2px solid transparent;
  border-image: linear-gradient(135deg, #d4af37, #8b6914, #d4af37) 1;
  border-radius: 0;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  overflow: hidden;
}

.stake-card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 12px;
  border: 2px solid transparent;
  background: linear-gradient(135deg, #d4af37, #8b6914, #d4af37) border-box;
  -webkit-mask: linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

.stake-card:active {
  transform: scale(0.96);
}

.stake-card:hover {
  box-shadow: 0 0 24px rgba(212, 175, 55, 0.3);
  transform: translateY(-2px);
}

.stake-amount {
  font-size: 32px;
  font-weight: bold;
  color: #d4af37;
  margin-bottom: 2px;
}

.stake-label {
  font-size: 12px;
  color: #8888aa;
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 10px;
}

.stake-buyin,
.stake-min {
  font-size: 11px;
  color: #aaaacc;
  margin-bottom: 12px;
}

.stake-players {
  font-size: 11px;
  color: #88aacc;
}

.stake-card.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.stake-card.disabled:hover {
  transform: none;
  box-shadow: none;
}

.stake-grid.loading {
  opacity: 0.5;
  pointer-events: none;
}

.player-count-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  background: rgba(212, 175, 55, 0.15);
  border-radius: 12px;
  font-size: 11px;
  color: #d4af37;
}

.badge-count {
  font-weight: bold;
}

/* -- Dev Panel -- */
.dev-panel {
  margin: 24px 20px 0;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.25);
}

.dev-panel-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  cursor: pointer;
  font-size: 13px;
  color: #8888aa;
  transition: background 0.2s;
}

.dev-panel-toggle:hover {
  background: rgba(255, 255, 255, 0.03);
}

.dev-toggle-icon {
  font-size: 16px;
}

.dev-toggle-arrow {
  margin-left: auto;
  font-size: 10px;
  transition: transform 0.3s ease;
}

.dev-panel-body {
  display: none;
  padding: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.dev-panel-body.open {
  display: block;
}

.dev-field {
  margin-bottom: 14px;
}

.dev-field:last-child {
  margin-bottom: 0;
}

.dev-field label {
  display: block;
  font-size: 11px;
  color: #8888aa;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 6px;
}

.dev-field input[type="text"] {
  width: 100%;
  padding: 10px 12px;
  background: #12121f;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  color: #00ff88;
  font-family: 'Courier New', Courier, monospace;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.dev-field input[type="text"]:focus {
  border-color: rgba(212, 175, 55, 0.5);
}

/* -- Avatar Selector -- */
.avatar-selector {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 6px;
}

.avatar-option {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color 0.2s, transform 0.2s;
}

.avatar-option:hover {
  transform: scale(1.1);
}

.avatar-option.selected {
  border-color: #d4af37;
  box-shadow: 0 0 8px rgba(212, 175, 55, 0.4);
}

.avatar-preview {
  width: 128px;
  height: 128px;
  background-image: url('../images/avatar-lsheet0.webp');
  background-size: 512px 512px;
  background-repeat: no-repeat;
  transform: scale(0.3125);
  transform-origin: top left;
}

/* ============================================================
   GAME SCREEN — Casino Table Style
   ============================================================ */
#game-screen {
  align-items: flex-start;
  justify-content: flex-start;
  overflow: hidden;
}

.game-wrapper {
  position: relative;
  width: 100%;
  max-width: 500px;
  height: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background: #0a0a18;
}

/* -- HUD Top Bar -- */
.game-hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: rgba(15, 15, 30, 0.95);
  border-bottom: 1px solid rgba(212, 175, 55, 0.25);
  z-index: 10;
  flex-shrink: 0;
}

.hud-left,
.hud-center,
.hud-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.hud-balance,
.hud-bet-info {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.hud-balance .balance-amount,
.hud-bet-info .balance-amount {
  font-size: 16px;
}

.hud-stake {
  font-size: 12px;
  color: #aaaacc;
  padding: 3px 10px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 12px;
}

.leave-button {
  width: 32px;
  height: 32px;
  border: none;
  background: rgba(255, 60, 60, 0.2);
  color: #ff6666;
  font-size: 20px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  line-height: 1;
}

.leave-button:hover {
  background: rgba(255, 60, 60, 0.4);
}

/* -- Table Surface (felt) -- */
.table-surface {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(ellipse 120% 70% at 50% 100%, rgba(0, 80, 40, 0.6) 0%, transparent 70%),
    linear-gradient(180deg, #0c2a15 0%, #0f4020 40%, #0c3018 100%);
  border-radius: 50% 50% 0 0 / 18% 18% 0 0;
  padding-top: 6px;
}

/* Subtle felt texture overlay */
.table-surface::before {
  content: '';
  position: absolute;
  inset: 0;
  background: url('../images/shared-0-sheet0.webp') 0 0 / 2048px 2048px no-repeat;
  opacity: 0.06;
  pointer-events: none;
}

/* Gold rim at top of table */
.table-surface::after {
  content: '';
  position: absolute;
  top: 0;
  left: 10%;
  right: 10%;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(212, 175, 55, 0.5), transparent);
  border-radius: 50%;
}

/* -- Dealer Zone -- */
.dealer-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 4px 16px 2px;
  flex-shrink: 0;
  z-index: 2;
}

.dealer-cards {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  min-height: 75px;
  padding-left: 20px; /* compensate for overlap offset */
}

/* Dealer card size */
.dealer-zone .card {
  width: 50px;
  height: 71px;
  border-radius: 5px;
  margin-left: -20px;
  position: relative;
}

.dealer-zone .card:first-child {
  margin-left: 0;
}

.dealer-zone .card .card-rank { font-size: 12px; }
.dealer-zone .card .card-suit-small { font-size: 9px; }
.dealer-zone .card .card-center-suit { font-size: 20px; }

/* -- Hand Badges (value circles) -- */
.hand-badge {
  display: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.85);
  color: #ffffff;
  font-size: 14px;
  font-weight: bold;
  align-items: center;
  justify-content: center;
  margin-top: 4px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  z-index: 5;
}

.hand-badge.visible {
  display: flex;
}

.hand-badge.bust {
  color: #ff4444;
  border-color: rgba(255, 68, 68, 0.5);
}

.hand-badge.blackjack {
  color: #d4af37;
  border-color: rgba(212, 175, 55, 0.6);
  background: rgba(30, 20, 0, 0.9);
}

.dealer-badge {
  margin-top: 6px;
}

/* -- Table Rules Text -- */
.table-rules-text {
  font-size: 10px;
  color: rgba(212, 175, 55, 0.45);
  text-transform: uppercase;
  letter-spacing: 2px;
  text-align: center;
  margin: 2px 0 2px;
  z-index: 2;
}

/* -- Seats Area (3-seat grid layout) -- */
.seats-area {
  display: grid;
  grid-template-columns: 28% 1fr 28%;
  grid-template-rows: 1fr auto;
  width: 100%;
  padding: 0 4px;
  flex: 1;
  min-height: 0;
  z-index: 2;
}

/* Individual seat */
.seat {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  min-width: 0;
}

.seat-left {
  grid-column: 1;
  grid-row: 1 / -1;
  justify-self: center;
  align-self: center;
}

.seat-right {
  grid-column: 3;
  grid-row: 1 / -1;
  justify-self: center;
  align-self: center;
}

.seat-main {
  grid-column: 2;
  grid-row: 1 / -1;
  justify-self: center;
  align-self: end;
  padding-bottom: 8px;
}

/* -- Seat Cards Container -- */
.seat-cards {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  min-height: 56px;
  position: relative;
}

/* Side seat cards */
.seat-left .seat-cards .card,
.seat-right .seat-cards .card {
  width: 38px;
  height: 54px;
  border-radius: 4px;
  margin-left: -14px;
}

.seat-left .seat-cards .card:first-child,
.seat-right .seat-cards .card:first-child {
  margin-left: 0;
}

.seat-left .seat-cards .card .card-rank,
.seat-right .seat-cards .card .card-rank { font-size: 9px; }
.seat-left .seat-cards .card .card-suit-small,
.seat-right .seat-cards .card .card-suit-small { font-size: 7px; }
.seat-left .seat-cards .card .card-center-suit,
.seat-right .seat-cards .card .card-center-suit { font-size: 14px; margin-top: 1px; }
.seat-left .seat-cards .card .card-corner,
.seat-right .seat-cards .card .card-corner { top: 1px; left: 2px; }

/* Main seat cards */
.seat-main .seat-cards .card {
  width: 56px;
  height: 80px;
  border-radius: 5px;
  margin-left: -18px;
}

.seat-main .seat-cards .card:first-child {
  margin-left: 0;
}

.seat-main .seat-cards .card .card-rank { font-size: 14px; }
.seat-main .seat-cards .card .card-suit-small { font-size: 11px; }
.seat-main .seat-cards .card .card-center-suit { font-size: 24px; }

/* Card fan rotation */
.seat-cards .card:nth-child(2) { transform: rotate(2deg); }
.seat-cards .card:nth-child(3) { transform: rotate(4deg); }
.seat-cards .card:nth-child(4) { transform: rotate(6deg); }
.seat-cards .card:nth-child(5) { transform: rotate(8deg); }
.seat-cards .card:nth-child(6) { transform: rotate(10deg); }

/* Split cards container */
.split-cards {
  margin-top: 6px;
}

.split-badge {
  margin-top: 2px;
}

/* Seat badge positioning */
.seat-badge {
  margin-top: 4px;
}

.main-badge {
  width: 36px;
  height: 36px;
  font-size: 16px;
}

/* -- Seat Result Labels -- */
.seat-result {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 14px;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 3px 10px;
  border-radius: 10px;
  z-index: 10;
  pointer-events: none;
  display: none;
  white-space: nowrap;
}

.seat-result.visible {
  display: block;
  animation: result-pop 0.4s ease-out;
}

.seat-result.win {
  background: rgba(34, 197, 94, 0.9);
  color: #fff;
}

.seat-result.lose,
.seat-result.bust {
  background: rgba(239, 68, 68, 0.9);
  color: #fff;
}

.seat-result.push {
  background: rgba(245, 158, 11, 0.9);
  color: #fff;
}

.seat-result.blackjack {
  background: rgba(212, 175, 55, 0.95);
  color: #1a1a2e;
}

.seat-main .seat-result {
  font-size: 18px;
  padding: 4px 14px;
}

/* Bust card greyed out */
.seat-cards .card.busted {
  filter: brightness(0.4) saturate(0.3);
}

/* -- Seat Tags (player name pill) -- */
.seat-tag {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px 3px 3px;
  background: rgba(0, 0, 0, 0.6);
  border-radius: 20px;
  margin-top: 6px;
  max-width: 100%;
}

.seat-tag-main {
  padding: 4px 12px 4px 4px;
}

.seat-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background-size: cover;
  flex-shrink: 0;
}

.seat-tag-main .seat-avatar {
  width: 28px;
  height: 28px;
}

.seat-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.seat-name {
  font-size: 10px;
  color: #ccccdd;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.seat-tag-main .seat-name {
  font-size: 12px;
}

.seat-bet {
  font-size: 9px;
  color: #d4af37;
  font-weight: bold;
}

.seat-tag-main .seat-bet {
  font-size: 10px;
}

.seat-bet:empty {
  display: none;
}

/* Active turn glow */
.seat.active-turn::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 12px;
  border: 2px solid rgba(212, 175, 55, 0.6);
  box-shadow: 0 0 12px rgba(212, 175, 55, 0.3);
  pointer-events: none;
  animation: pulse-glow 1.5s ease-in-out infinite;
}

@keyframes pulse-glow {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

/* -- Side Bet Zones -- */
.side-bet-zones {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}

.side-bet-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 68px;
  height: 34px;
  border: 1.5px dashed rgba(212, 175, 55, 0.35);
  border-radius: 17px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  position: relative;
}

.side-bet-zone:hover {
  border-color: rgba(212, 175, 55, 0.6);
  background: rgba(212, 175, 55, 0.08);
}

.side-bet-zone.active {
  border-color: #d4af37;
  background: rgba(212, 175, 55, 0.15);
}

.side-bet-zone.won {
  border-color: #22c55e;
  background: rgba(34, 197, 94, 0.15);
}

.side-bet-zone.lost {
  border-color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
}

.side-bet-label {
  font-size: 7px;
  color: rgba(212, 175, 55, 0.6);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  line-height: 1;
}

.side-bet-amount {
  font-size: 10px;
  color: #d4af37;
  font-weight: bold;
}

.side-bet-amount:empty {
  display: none;
}

/* -- Hand Tabs (Split) -- */
#hand-tabs {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 4px;
}

.hand-tab {
  padding: 4px 14px;
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  color: #8888aa;
  font-family: 'GameFont', sans-serif;
  font-size: 11px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.hand-tab.active {
  border-color: #d4af37;
  color: #d4af37;
  background: rgba(212, 175, 55, 0.1);
}

/* -- Status Text -- */
.status-text {
  text-align: center;
  padding: 8px 16px;
  font-size: 14px;
  color: #d4af37;
  text-transform: uppercase;
  letter-spacing: 1px;
  flex-shrink: 0;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 8px;
  margin: 2px 16px;
  z-index: 5;
}

/* -- Card Elements (CSS-only) -- */
.card {
  width: 52px;
  height: 74px;
  border-radius: 5px;
  flex-shrink: 0;
  position: relative;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

.card.card-small {
  width: 40px;
  height: 57px;
  border-radius: 4px;
}

/* CSS Card face */
.css-card {
  background: linear-gradient(135deg, #fefefe 0%, #f0ede6 100%);
  border: 1.5px solid rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.card-corner {
  position: absolute;
  top: 3px;
  left: 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
}

.card-rank {
  font-family: 'Georgia', 'Times New Roman', serif;
  font-size: 13px;
  font-weight: bold;
  line-height: 1;
}

.card-suit-small {
  font-size: 10px;
  line-height: 1;
  margin-top: 0px;
}

.card-center-suit {
  font-size: 22px;
  line-height: 1;
  margin-top: 4px;
  opacity: 0.85;
}

/* Small card adjustments */
.card-small .card-corner {
  top: 2px;
  left: 3px;
}

.card-small .card-rank {
  font-size: 10px;
}

.card-small .card-suit-small {
  font-size: 8px;
}

.card-small .card-center-suit {
  font-size: 16px;
  margin-top: 2px;
}

/* Card back */
.css-card.card-back {
  background: linear-gradient(135deg, #1e3a5f, #2a5080);
  border-color: #0f2540;
  color: transparent;
}

.card-back-pattern {
  position: absolute;
  inset: 3px;
  border-radius: 3px;
  border: 1.5px solid rgba(212, 175, 55, 0.4);
  background:
    repeating-linear-gradient(
      45deg,
      transparent,
      transparent 3px,
      rgba(212, 175, 55, 0.08) 3px,
      rgba(212, 175, 55, 0.08) 6px
    );
}

.card-small .card-back-pattern {
  inset: 2px;
  border-radius: 2px;
}

/* -- Card Animations -- */
.card-dealt {
  animation: deal-card 0.3s ease forwards;
}

.card-flip {
  animation: flip-card 0.4s ease forwards;
}

@keyframes deal-card {
  0% {
    transform: translateY(-40px) scale(0.8);
    opacity: 0;
  }
  100% {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

@keyframes flip-card {
  0% { transform: rotateY(0deg); }
  50% { transform: rotateY(90deg); }
  100% { transform: rotateY(0deg); }
}

@keyframes result-pop {
  0% {
    transform: translate(-50%, -50%) scale(0.3);
    opacity: 0;
  }
  60% {
    transform: translate(-50%, -50%) scale(1.1);
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
  }
}

/* -- Timer Bar -- */
#timer-bar {
  position: relative;
  width: 100%;
  height: 6px;
  background: rgba(0, 0, 0, 0.3);
  flex-shrink: 0;
  display: none;
  z-index: 5;
}

#timer-bar.active {
  display: block;
}

.timer-fill {
  height: 100%;
  background: linear-gradient(90deg, #00cc66, #33ff99);
  border-radius: 0 3px 3px 0;
  width: 100%;
  transition: width 0.1s linear;
}

.timer-fill.warning {
  background: linear-gradient(90deg, #ff6600, #ffaa00);
}

.timer-fill.danger {
  background: linear-gradient(90deg, #ff2222, #ff6644);
}

.timer-seconds {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 9px;
  color: #ffffff;
  font-weight: bold;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

/* -- Bottom Panel -- */
.bottom-panel {
  flex-shrink: 0;
  background: rgba(15, 15, 30, 0.95);
  border-top: 1px solid rgba(212, 175, 55, 0.15);
}

/* -- Action Buttons -- */
#action-buttons {
  display: none;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  padding: 12px 16px;
}

#action-buttons.active {
  display: flex;
}

.action-btn {
  padding: 12px 22px;
  border: none;
  border-radius: 24px;
  font-family: 'GameFont', sans-serif;
  font-size: 15px;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 1px;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.2s, opacity 0.2s;
  min-width: 80px;
  color: #ffffff;
}

.action-btn:active { transform: scale(0.94); }
.action-btn:disabled { opacity: 0.35; cursor: not-allowed; transform: none; }

.btn-hit {
  background: linear-gradient(180deg, #22c55e, #16a34a);
  box-shadow: 0 4px 12px rgba(34, 197, 94, 0.3);
}
.btn-hit:hover:not(:disabled) { box-shadow: 0 4px 20px rgba(34, 197, 94, 0.5); }

.btn-stand {
  background: linear-gradient(180deg, #ef4444, #dc2626);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}
.btn-stand:hover:not(:disabled) { box-shadow: 0 4px 20px rgba(239, 68, 68, 0.5); }

.btn-double {
  background: linear-gradient(180deg, #3b82f6, #2563eb);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}
.btn-double:hover:not(:disabled) { box-shadow: 0 4px 20px rgba(59, 130, 246, 0.5); }

.btn-split {
  background: linear-gradient(180deg, #a855f7, #9333ea);
  box-shadow: 0 4px 12px rgba(168, 85, 247, 0.3);
}
.btn-split:hover:not(:disabled) { box-shadow: 0 4px 20px rgba(168, 85, 247, 0.5); }

/* -- Betting UI (redesigned) -- */
#betting-ui {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 12px 16px 16px;
}

#betting-ui.active {
  display: flex;
}

.bet-adjuster {
  display: flex;
  align-items: center;
  gap: 12px;
}

.bet-adj-btn {
  width: 44px;
  height: 44px;
  border: 2px solid rgba(212, 175, 55, 0.5);
  border-radius: 50%;
  background: rgba(212, 175, 55, 0.1);
  color: #d4af37;
  font-size: 24px;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.1s, background 0.2s;
  line-height: 1;
}

.bet-adj-btn:hover {
  background: rgba(212, 175, 55, 0.2);
}

.bet-adj-btn:active {
  transform: scale(0.9);
}

.bet-amount-box {
  font-size: 26px;
  font-weight: bold;
  color: #d4af37;
  min-width: 100px;
  text-align: center;
  padding: 6px 16px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 12px;
  border: 1px solid rgba(212, 175, 55, 0.2);
}

.bet-multipliers {
  display: flex;
  gap: 8px;
}

.bet-mult-btn {
  padding: 6px 18px;
  border: 2px solid rgba(212, 175, 55, 0.4);
  border-radius: 16px;
  background: rgba(212, 175, 55, 0.08);
  color: #d4af37;
  font-family: 'GameFont', sans-serif;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  transition: transform 0.1s, background 0.2s, border-color 0.2s;
}

.bet-mult-btn:hover {
  background: rgba(212, 175, 55, 0.2);
  border-color: rgba(212, 175, 55, 0.6);
}

.bet-mult-btn:active {
  transform: scale(0.95);
}

.bet-mult-btn.selected {
  background: linear-gradient(135deg, #d4af37, #b8941e);
  color: #1a1a2e;
  border-color: #d4af37;
}

.confirm-bet-btn {
  padding: 12px 48px;
  border: none;
  border-radius: 24px;
  background: linear-gradient(180deg, #d4af37, #b8941e);
  color: #1a1a2e;
  font-family: 'GameFont', sans-serif;
  font-size: 16px;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 2px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.2s;
  box-shadow: 0 4px 16px rgba(212, 175, 55, 0.3);
}

.confirm-bet-btn:hover {
  transform: scale(1.03);
  box-shadow: 0 4px 24px rgba(212, 175, 55, 0.5);
}

.confirm-bet-btn:active { transform: scale(0.97); }
.confirm-bet-btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

.bet-bottom-row {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
}

.auto-bet-toggle {
  padding: 12px 16px;
  border: 2px solid #666;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.08);
  color: #aaa;
  font-family: 'GameFont', sans-serif;
  font-size: 12px;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 1px;
  cursor: pointer;
  transition: all 0.2s;
}

.auto-bet-toggle.active {
  border-color: #d4af37;
  background: rgba(212, 175, 55, 0.2);
  color: #d4af37;
}

.auto-bet-toggle:active { transform: scale(0.95); }

/* -- Result Overlay -- */
#result-overlay {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 50;
  justify-content: center;
  align-items: center;
}

#result-overlay.active {
  display: flex;
}

.result-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  animation: slide-in-top 0.5s ease-out;
}

.result-text {
  font-size: 42px;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 5px;
  text-shadow: 0 0 30px rgba(212, 175, 55, 0.5);
}

.result-text.win { color: #22c55e; text-shadow: 0 0 30px rgba(34, 197, 94, 0.5); }
.result-text.lose { color: #ef4444; text-shadow: 0 0 30px rgba(239, 68, 68, 0.5); }
.result-text.push { color: #f59e0b; text-shadow: 0 0 30px rgba(245, 158, 11, 0.5); }
.result-text.blackjack { color: #d4af37; text-shadow: 0 0 30px rgba(212, 175, 55, 0.6); }

.result-amount { font-size: 26px; font-weight: bold; }
.result-amount.win { color: #22c55e; }
.result-amount.lose { color: #ef4444; }
.result-amount.push { color: #f59e0b; }

.result-continue-btn {
  margin-top: 8px;
  padding: 10px 36px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  font-family: 'GameFont', sans-serif;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 2px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

.result-continue-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.5);
}

/* -- Insurance Prompt -- */
#insurance-prompt {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 40;
  justify-content: center;
  align-items: center;
}

#insurance-prompt.active {
  display: flex;
}

.insurance-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 28px 36px;
  background: linear-gradient(135deg, #2d2d4a, #1e1e36);
  border: 2px solid rgba(212, 175, 55, 0.4);
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
  animation: slide-in-top 0.4s ease-out;
}

.insurance-text {
  font-size: 16px;
  color: #ffffff;
  text-align: center;
  margin: 0;
  line-height: 1.4;
}

.insurance-buttons {
  display: flex;
  gap: 14px;
}

.insurance-yes {
  padding: 10px 32px;
  border: none;
  border-radius: 24px;
  background: linear-gradient(180deg, #d4af37, #b8941e);
  color: #1a1a2e;
  font-family: 'GameFont', sans-serif;
  font-size: 15px;
  font-weight: bold;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.2s;
}

.insurance-yes:hover { transform: scale(1.05); box-shadow: 0 4px 16px rgba(212, 175, 55, 0.4); }
.insurance-yes:active { transform: scale(0.95); }

.insurance-no {
  padding: 10px 32px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  font-family: 'GameFont', sans-serif;
  font-size: 15px;
  font-weight: bold;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform 0.15s, background 0.2s;
}

.insurance-no:hover { background: rgba(255, 255, 255, 0.15); transform: scale(1.05); }
.insurance-no:active { transform: scale(0.95); }

/* ============================================================
   SHARED ANIMATIONS
   ============================================================ */
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

@keyframes slide-in-top {
  0% {
    transform: translateY(-100%);
    opacity: 0;
  }
  100% {
    transform: translateY(0);
    opacity: 1;
  }
}

/* ============================================================
   LANDSCAPE WARNING
   ============================================================ */
#landscape-warning {
  display: none;
  position: fixed;
  inset: 0;
  background: #1a1a2e;
  z-index: 9999;
  justify-content: center;
  align-items: center;
}

.landscape-warning-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  text-align: center;
  padding: 40px;
}

.rotate-icon {
  font-size: 64px;
  color: #d4af37;
  animation: pulse 1.5s ease-in-out infinite;
}

.landscape-warning-content p {
  font-size: 18px;
  color: #ccccdd;
  max-width: 280px;
  line-height: 1.5;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

/* Portrait base (390px) - default styles above */

/* Slightly larger phones */
@media (min-width: 414px) {
  .stake-amount {
    font-size: 36px;
  }

  .action-btn {
    padding: 14px 24px;
    font-size: 16px;
  }

  /* Scale up main seat cards on larger phones */
  .seat-main .seat-cards .card {
    width: 60px;
    height: 86px;
  }

  .dealer-zone .card {
    width: 54px;
    height: 77px;
  }
}

/* Max-width container for larger screens */
@media (min-width: 501px) {
  .lobby-wrapper,
  .game-wrapper {
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.5);
  }
}

/* Landscape orientation warning */
@media (orientation: landscape) and (max-height: 500px) {
  .screen {
    display: none !important;
  }

  #landscape-warning {
    display: flex !important;
  }
}

/* Tablets in portrait - scale up slightly */
@media (min-width: 600px) and (orientation: portrait) {
  .seat-main .seat-cards .card {
    width: 64px;
    height: 91px;
  }

  .dealer-zone .card {
    width: 56px;
    height: 80px;
  }

  .seat-left .seat-cards .card,
  .seat-right .seat-cards .card {
    width: 42px;
    height: 60px;
  }

  .result-text {
    font-size: 50px;
  }

  .result-amount {
    font-size: 32px;
  }

  .action-btn {
    padding: 16px 28px;
    font-size: 18px;
    min-width: 100px;
  }
}

/* Desktop / large tablets */
@media (min-width: 1024px) {
  body {
    display: flex;
    justify-content: center;
    align-items: center;
    background: #111122;
  }

  .screen {
    max-width: 500px;
    margin: 0 auto;
    border-radius: 24px;
    overflow: hidden;
    box-shadow: 0 0 60px rgba(0, 0, 0, 0.6);
  }
}
