/* ==========================================================================
   APPLE OF FORTUNE - 1XGAMES MOBILE REPLICA
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;600;700;800&family=Inter:wght@400;500;600;700&display=swap');

:root {
  --font-main: 'Roboto', -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', Arial, sans-serif;
  --font-alt: 'Roboto', -apple-system, BlinkMacSystemFont, 'Inter', sans-serif;
  
  /* 1xBet / Apple of Fortune Color Palette */
  --bg-dark: #071510;
  --bg-surface: rgba(11, 28, 22, 0.92);
  --bg-card: rgba(18, 42, 33, 0.85);
  
  --primary-blue: #478cd1;
  --primary-blue-hover: #3b7ec2;
  --primary-blue-gradient: linear-gradient(180deg, #478cd1 0%, #3573b2 100%);
  
  --accent-green: #5fa946;
  --accent-neon-green: #5fa946;
  --cashout-green-grad: linear-gradient(180deg, #5fa946 0%, #468832 100%);
  
  --gold-accent: #f5a623;
  --danger-red: #e74c3c;
  
  --pill-active-bg: #5fa946;
  --pill-active-text: #ffffff;
  --pill-inactive-bg: rgba(4, 18, 12, 0.65);
  --pill-inactive-text: #ffffff;
  
  --text-primary: #ffffff;
  --text-secondary: #95afc0;
  --text-muted: #576574;
  
  --shadow-disc: 0 4px 12px rgba(0, 0, 0, 0.45);
  --shadow-active: 0 0 16px rgba(46, 204, 113, 0.6), inset 0 0 8px rgba(255, 255, 255, 0.3);

  /* Precise layout sizing: 440px max width */
  --pill-width: clamp(52px, min(15cqw, 66px), 66px);
  --pill-height: 28px;
  --pill-disc-gap: 8px;
  --board-pad: 8px;
  --disc-size: clamp(48px, calc((100cqw - (var(--board-pad) * 2) - var(--pill-width) - var(--pill-disc-gap) - 10px) / 5), 66px);
  --row-height: 68px;
  --peek-height: 8px;
  --board-top-gap: 26px;
  --board-viewport-height: calc(6 * var(--row-height) + var(--peek-height) + var(--board-top-gap));
}

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

.hidden {
  display: none !important;
}

html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background-color: #040907;
  font-family: var(--font-main);
  color: var(--text-primary);
}

/* ==========================================================================
   APP SHELL / RESPONSIVE MOBILE CONTAINER
   ========================================================================== */
#appWrapper {
  position: relative;
  container-type: inline-size;
  width: 100%;
  max-width: 440px;
  height: 100%;
  margin: 0 auto;
  background: #091a13 url('assets/bg.jpg') no-repeat center bottom;
  background-size: cover;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-sizing: border-box;

  /* Precise layout sizing: 440px max width */
  --header-height: 48px;
  --board-pad: 5px;
  --pill-width: 62px;
  --pill-height: 26px;
  --pill-disc-gap: 5px;
  --cell-gap: 1.5px;
  --disc-size: clamp(52px, calc((100cqw - (var(--board-pad) * 2) - var(--pill-width) - var(--pill-disc-gap) - (var(--cell-gap) * 4)) / 5), 71.4px);
  --row-height: calc(var(--disc-size) + 1.5px);
  --peek-height: 8px;
  --board-top-gap: 6px;
}

/* Particles Canvas (Fireflies overlay - starts below header) */
#particlesCanvas {
  position: absolute;
  top: 65px;
  left: 0;
  width: 100%;
  height: calc(100% - 65px);
  pointer-events: none;
  z-index: 1;
}

/* Confetti Canvas (Celebration) */
#confettiCanvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 90;
}

/* ==========================================================================
   HEADER / TOP BAR (Pixel-Perfect 1xBet)
   ========================================================================== */
.top-header {
  position: relative;
  z-index: 10;
  height: var(--header-height);
  padding: 6px 12px 4px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: linear-gradient(180deg, #010403 0%, #020906 50%, rgba(2, 8, 5, 0.88) 100%);
  flex-shrink: 0;
  width: 100%;
  box-sizing: border-box;
}

.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.nav-btn {
  background: none;
  border: none;
  color: #ffffff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-radius: 50%;
  transition: transform 0.15s ease;
}

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

.hdr-icon {
  width: 20px;
  height: 20px;
  display: block;
  object-fit: contain;
  opacity: 0.72;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.6));
  pointer-events: none;
}

.hdr-back-img {
  width: 18px;
  height: 18px;
  opacity: 0.85;
}

/* Balance Capsule with green plus */
.balance-capsule {
  display: flex;
  align-items: center;
  background: rgba(0, 0, 0, 0.42);
  border: none;
  border-radius: 12px;
  padding: 2px 3px 2px 10px;
  gap: 8px;
  cursor: pointer;
  box-shadow: none;
}

.balance-amount {
  font-size: 10.5px;
  font-weight: 400;
  color: rgba(220, 220, 220, 0.92);
  letter-spacing: 0.1px;
  font-variant-numeric: tabular-nums;
  font-family: -apple-system, BlinkMacSystemFont, "Roboto", "Segoe UI", Arial, sans-serif;
  text-shadow: none;
}

.btn-add-funds {
  background: #357a3e;
  border: none;
  width: 20px;
  height: 16px;
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-weight: 500;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  box-shadow: none;
  transition: transform 0.15s;
}

.btn-add-funds:active {
  transform: scale(0.9);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.game-title-sub {
  text-align: center;
  font-size: 8.5px;
  font-weight: 400;
  letter-spacing: 0.5px;
  color: rgba(220, 220, 220, 0.78);
  text-transform: uppercase;
  font-family: -apple-system, BlinkMacSystemFont, "Roboto", "Segoe UI", Arial, sans-serif;
  margin-top: 2px;
}

/* ==========================================================================
   TOWER / LADDER BOARD VIEWPORT & CONTAINER (10 ROWS x 5 CELLS)
   ========================================================================== */
.board-viewport {
  position: relative;
  z-index: 5;
  width: 100%;
  height: calc(66.67% - var(--header-height));
  flex: 0 0 calc(66.67% - var(--header-height));
  overflow: hidden; /* Exactly 6 rows visible within upper 2/3 of screen */
  flex-shrink: 0;
  box-sizing: border-box;
}

/* Atmospheric canopy vignette shading top rows exactly like Left image */
.board-viewport::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 52%;
  background: linear-gradient(180deg, 
    rgba(2, 8, 5, 0.88) 0%, 
    rgba(2, 8, 5, 0.58) 35%, 
    rgba(2, 8, 5, 0.15) 70%, 
    transparent 100%
  );
  pointer-events: none;
  z-index: 8;
}

.board-container {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  display: flex;
  flex-direction: column-reverse; /* Row 1 at the bottom, Row 10 at top */
  gap: 0px; /* Zero vertical gap: rows touch directly without overlapping! */
  padding: var(--board-top-gap) var(--board-pad) var(--peek-height) var(--board-pad);
  box-sizing: border-box;
  transition: transform 0.45s cubic-bezier(0.25, 1, 0.5, 1);
  will-change: transform;
}

/* Atmospheric Sunlight / God Ray Stream (Matches Left Image) */
.board-container::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  background: linear-gradient(125deg, 
    rgba(255, 245, 190, 0.09) 0%, 
    rgba(255, 230, 140, 0.05) 25%, 
    transparent 60%
  );
  z-index: 6;
}

/* Empty Glade Spacer (reveals the lower glade and tropical palm plant) */
.glade-spacer {
  flex: 1 1 0px;
  min-height: 0px;
  pointer-events: none;
}

/* Soft amber sunbeam haze across upper columns 3-4 (Matches Left Image) */
.god-ray-cloud {
  position: absolute;
  top: 34%;
  right: 18%;
  width: 220px;
  height: 160px;
  background: radial-gradient(ellipse at 50% 50%, rgba(255, 215, 60, 0.22) 0%, rgba(255, 185, 40, 0.08) 50%, transparent 75%);
  pointer-events: none;
  z-index: 7;
  mix-blend-mode: screen;
  filter: blur(14px);
}

/* Single Row */
.tower-row {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: var(--pill-disc-gap); /* Exact 8px gap between pill and cells! */
  width: 100%;
  height: var(--row-height);
  box-sizing: border-box;
  transition: opacity 0.4s ease, transform 0.3s ease;
}

/* Row Depth Opacities (Upper rows sink into dark canopy as seen on Left, while pills stay 100% crisp) */
.tower-row[data-depth="0"] .row-cells { opacity: 1.0; }
.tower-row[data-depth="1"] .row-cells { opacity: 0.95; }
.tower-row[data-depth="2"] .row-cells { opacity: 0.88; }
.tower-row[data-depth="3"] .row-cells { opacity: 0.72; }
.tower-row[data-depth="4"] .row-cells { opacity: 0.55; }
.tower-row[data-depth="5"] .row-cells { opacity: 0.40; }
.tower-row[data-depth="6"] .row-cells,
.tower-row[data-depth="7"] .row-cells,
.tower-row[data-depth="8"] .row-cells,
.tower-row[data-depth="9"] .row-cells { opacity: 0.30; }

/* Level Multiplier Pill (Left Side) - Matches Left Image */
.level-pill {
  position: relative;
  z-index: 10; /* Sits above canopy vignette so text is pure 100% white */
  width: var(--pill-width);
  height: var(--pill-height);
  flex-shrink: 0;
  border-radius: 6px; /* Authentic 6px rounded rect, NOT 999px capsule! */
  background: rgba(4, 18, 12, 0.70);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  color: #ffffff !important;
  letter-spacing: 0px;
  transition: all 0.25s ease;
  box-shadow: none;
  font-family: var(--font-main);
  opacity: 1 !important; /* Pills remain 100% crisp and readable */
}

/* When the level is currently ACTIVE (Matches Left Image: authentic matte green #5fa946) */
.tower-row.active .level-pill {
  background: #5fa946;
  color: #ffffff !important;
  font-size: 11.5px;
  font-weight: 700;
  border-radius: 6px;
  border: none;
  box-shadow: none;
}

/* When the level is already WON / CLEARED: submerged pill is hidden */
.tower-row.cleared .level-pill {
  opacity: 0 !important;
  visibility: hidden;
}

/* The 5 Cells Container in each row */
.row-cells {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: var(--cell-gap); /* Barely visible 1.5px gap between discs matching official screenshot! */
}

/* Individual Cell (Round Disc) */
.cell {
  position: relative;
  width: var(--disc-size);
  height: var(--disc-size);
  border-radius: 50%;
  perspective: 600px;
  cursor: default;
  flex-shrink: 0;
}

.cell.clickable {
  cursor: pointer;
}

.cell-inner {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  transform-style: preserve-3d;
}

.cell.flipped .cell-inner {
  transform: rotateY(180deg);
}

/* Front Face: The Wooden Disc */
.cell-front, .cell-back {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  overflow: hidden;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.35);
}

.cell-front {
  background-size: 100% 100%;
  background-position: center;
  background-repeat: no-repeat;
  transition: transform 0.15s ease, filter 0.15s ease;
}

/* Inactive plain wooden disc (Terracotta/mahogany stylized disc from Image 2) */
.cell-front.plain {
  background-image: url('assets/wood_plain.png');
}

/* Active wooden disc with carved arrow (Honey-amber arrow token from Image 2) */
.cell-front.active-arrow {
  background-image: url('assets/wood_active.png');
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.4));
}

.cell.clickable:hover .cell-front.active-arrow {
  transform: scale(1.05);
}

.cell.clickable:active .cell-front.active-arrow {
  transform: scale(0.94);
}

/* Back Face: Revealed (Good or Bad Apple) */
.cell-back {
  transform: rotateY(180deg);
  background-size: 100% 100%;
  background-position: center;
  background-repeat: no-repeat;
}

.cell-back.good-apple {
  background-image: url('assets/apple_good.png');
  box-shadow: 0 0 14px rgba(46, 204, 113, 0.6);
}

.cell-back.bad-apple {
  background-image: url('assets/apple_bad.png');
  box-shadow: 0 0 16px rgba(231, 76, 60, 0.7);
  animation: shake-fail 0.5s ease-in-out;
}

/* When revealed during loss as preview (Matches Image 3: crisp, bright and fully saturated) */
.cell-back.hint {
  filter: brightness(0.95);
}

@keyframes shake-fail {
  0%, 100% { transform: rotateY(180deg) translate3d(0, 0, 0); }
  20%, 60% { transform: rotateY(180deg) translate3d(-4px, 0, 0); }
  40%, 80% { transform: rotateY(180deg) translate3d(4px, 0, 0); }
}

/* ==========================================================================
   BOTTOM DOCK (BETTING & CASHOUT CONTROLS)
   ========================================================================== */
.bottom-dock {
  position: relative;
  z-index: 15;
  background: #000000;
  border-top: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  height: 72px;
  box-shadow: none;
  flex-shrink: 0;
  margin-top: auto;
  box-sizing: border-box;
}

/* MODE 1: BETTING CONTROLS */
.bet-controls {
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: 100%;
  padding: 4px 8px 6px 8px;
  background: rgba(6, 18, 14, 0.96);
}

/* Quick Bet Presets (MIN, X2, X/2, MAX) */
.presets-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
}

.btn-preset {
  background: #365576;
  border: none;
  border-radius: 3px;
  height: 20px; /* Slim preset buttons */
  color: #8fb5db;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.3px;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.btn-preset.primary-preset {
  background: #3882e5;
  color: #ffffff;
  font-weight: 800;
}

.btn-preset:active {
  transform: scale(0.95);
  filter: brightness(0.9);
}

/* Input Row & MISE Button */
.input-action-row {
  display: flex;
  gap: 5px;
  align-items: stretch;
  height: 29px; /* Slimmed from 36px */
}

.input-container {
  flex: 1;
  background: #18283c;
  border: 1px solid rgba(56, 130, 229, 0.25);
  border-radius: 4px;
  padding: 1px 8px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative;
}

.bet-input-box {
  background: transparent;
  border: none;
  border-bottom: 1.5px solid #2f4f70;
  color: #ffffff;
  font-size: 13px; /* Compact */
  font-weight: 700;
  outline: none;
  width: 100%;
  padding-bottom: 0px;
  line-height: 1.1;
  font-family: var(--font-main);
}

.input-caption {
  font-size: 8px;
  color: #6888a6;
  font-weight: 500;
  margin-top: 0px;
  line-height: 1;
}

.btn-mise {
  background: #3882e5;
  border: none;
  border-radius: 4px;
  width: 78px;
  padding: 0 6px;
  color: #ffffff;
  font-size: 12px; /* Compact blue MISE button */
  font-weight: 800;
  letter-spacing: 0.5px;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(56, 130, 229, 0.35);
  transition: transform 0.15s, box-shadow 0.15s;
}

.btn-mise:active {
  transform: scale(0.95);
  box-shadow: 0 1px 4px rgba(56, 130, 229, 0.3);
}

/* Footer Utility Tabs */
.footer-tools-row {
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding-top: 1px;
}

.footer-tool-btn {
  background: none;
  border: none;
  color: #8da4b8;
  font-size: 9.5px; /* Compact */
  font-weight: 700;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  padding: 1px 5px;
  border-radius: 3px;
  transition: color 0.15s;
}

.footer-tool-btn:hover {
  color: #ffffff;
}

.footer-tool-divider {
  width: 1px;
  height: 10px;
  background: rgba(255, 255, 255, 0.15);
}

/* MODE 2: IN-GAME CASHOUT CONTROLS (Flat black bar + Slim Blue button matching official 1xBet) */
.cashout-controls {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  width: 100%;
  height: 72px;
  background: #000000;
  padding: 8px 8px 11px 8px;
  box-sizing: border-box;
  animation: fadeIn 0.25s ease-out;
}

.current-win-badge {
  background: transparent;
  border: none;
  border-radius: 0;
  width: 100%;
  height: 18px;
  line-height: 18px;
  text-align: center;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: #ffffff;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.current-win-badge span {
  color: #ffffff;
  font-size: 10.5px;
  font-weight: 700;
}

.btn-cashout {
  background: #478cd1; /* Signature official 1xBet blue rgb(71,140,209) */
  border: none;
  border-radius: 5px;
  height: 30px;
  width: 100%;
  margin: 0;
  color: #ffffff;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.3px;
  cursor: pointer;
  box-shadow: none;
  transition: filter 0.15s, transform 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  text-transform: uppercase;
  box-sizing: border-box;
}

.btn-cashout:active {
  filter: brightness(0.9);
  transform: scale(0.99);
}

.btn-cashout:active {
  transform: scale(0.98);
  filter: brightness(0.92);
}

/* MODE 3: DEFEAT CONTROLS */
.loss-controls {
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: 100%;
}

.btn-replay {
  background: #3882e5;
  border: none;
  border-radius: 4px;
  height: 29px;
  color: #ffffff;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: transform 0.15s;
}

.btn-replay:active {
  transform: scale(0.96);
}

.btn-new-bet {
  background: #111d28;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  height: 27px;
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: transform 0.15s;
}

.btn-new-bet:active {
  transform: scale(0.96);
}

/* ==========================================================================
   WIN / LOSS TOAST NOTIFICATIONS
   ========================================================================== */
.toast-banner {
  position: absolute;
  top: 75px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  padding: 10px 20px;
  border-radius: 30px;
  font-size: 14px;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
}

.toast-banner.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast-banner.win {
  background: linear-gradient(135deg, #11998e, #38ef7d);
  color: #ffffff;
  border: 1px solid #7eff9e;
}

.toast-banner.loss {
  background: linear-gradient(135deg, #cb2d3e, #ef473a);
  color: #ffffff;
  border: 1px solid #ff7b7b;
}

/* ==========================================================================
   MODALS (Conditions Générales, Recharge, Paramètres)
   ========================================================================== */
.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 200;
  display: flex;
  flex-direction: column;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  overscroll-behavior: contain;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #ffffff;
  color: #2c3e50;
  overflow: hidden;
}

/* Rules Modal specific (matches Screenshot 1) */
.rules-header {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid #eef2f5;
  background: #ffffff;
  gap: 14px;
}

.rules-back-btn {
  background: none;
  border: none;
  color: #2980b9;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.rules-header-title {
  flex: 1;
  text-align: center;
  font-size: 16px;
  font-weight: 700;
  color: #34495e;
  margin-right: 24px; /* balance out the back button */
}

.rules-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  font-family: var(--font-alt);
  font-size: 13.5px;
  line-height: 1.55;
  color: #4a6572;
}

.rules-game-title {
  font-size: 18px;
  font-weight: 800;
  color: #1e3c72;
  font-family: var(--font-main);
}

.rules-game-subtitle {
  font-size: 13.5px;
  color: #5c788d;
  font-style: italic;
  margin-top: -8px;
}

.rules-section-title {
  font-size: 15px;
  font-weight: 700;
  color: #1e3c72;
  margin-top: 4px;
}

.rules-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-left: 0;
  list-style: none;
}

.rules-list li {
  position: relative;
  padding-left: 20px;
}

.rules-list li::before {
  content: attr(data-num);
  position: absolute;
  left: 0;
  font-weight: 700;
  color: #2980b9;
}

.rules-footer-notes {
  font-size: 12px;
  color: #7f8c8d;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-top: 1px solid #eef2f5;
  padding-top: 14px;
}

/* Dark Modals for Settings & Funds */
.modal-content.dark {
  background: #0d221a;
  color: #ffffff;
  border-top: 2px solid #2ecc71;
  border-radius: 20px 20px 0 0;
  margin-top: auto;
  flex: initial;
  max-height: 80%;
  padding: 20px 18px 24px 18px;
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.8);
}

.dark-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.dark-modal-title {
  font-size: 16px;
  font-weight: 700;
  color: #ffffff;
}

.btn-close-modal {
  background: none;
  border: none;
  color: #8da4b8;
  font-size: 20px;
  cursor: pointer;
}

.funds-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.btn-add-amount {
  background: #143528;
  border: 1px solid rgba(46, 204, 113, 0.3);
  border-radius: 8px;
  padding: 12px;
  color: #2ecc71;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-add-amount:active {
  background: #2ecc71;
  color: #000;
}

/* Settings List */
.settings-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.settings-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #254032;
  transition: 0.3s;
  border-radius: 24px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.3s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: #2ecc71;
}

input:checked + .slider:before {
  transform: translateX(20px);
}

/* ==========================================================================
   BOARD SPINNER LOADER (Exact replica of Image 1)
   ========================================================================== */
.board-spinner {
  position: absolute;
  top: 48%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 60;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.spinner-arc {
  width: 38px;
  height: 38px;
  border: 3.5px solid rgba(56, 189, 248, 0.15);
  border-top-color: #38bdf8;
  border-right-color: #38bdf8;
  border-radius: 50%;
  animation: spinLoader 0.65s linear infinite;
  box-shadow: 0 0 14px rgba(56, 189, 248, 0.5);
}

@keyframes spinLoader {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* ==========================================================================
   LOSS OVERLAY & DEFEAT CONTROLS (Exact replica of Image 3)
   ========================================================================== */
/* ==========================================================================
   LOSS OVERLAY & DEFEAT CONTROLS (Exact replica of Image 3)
   ========================================================================== */
.loss-overlay {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 100%;
  background: rgba(0, 0, 0, 0.40); /* Exact gentle darkening without any blur */
  backdrop-filter: none; /* NO BLUR: Matches Image 3 where background and apples remain 100% sharp */
  -webkit-backdrop-filter: none;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  animation: fadeIn 0.25s ease-out;
  pointer-events: none;
}

.loss-message-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 0 20px;
  margin-top: -20px;
  pointer-events: none;
}

.loss-title {
  font-size: 20px;
  font-weight: 700;
  color: #ffffff;
  line-height: 1.35;
  text-align: center;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.95), 0 0 4px rgba(0, 0, 0, 0.9);
  max-width: 320px;
}

.loss-subtitle {
  font-size: 13.5px;
  color: rgba(255, 255, 255, 0.75);
  font-weight: 500;
  margin-top: 6px;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.9);
}

/* DEFEAT CONTROLS: REJOUER & NOUVELLE MISE (Exact replica of Image 3) */
.loss-controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  animation: fadeIn 0.25s ease-out;
}

.btn-replay {
  background: #3882e5; /* Exact vibrant blue from Image 3 */
  border: none;
  border-radius: 6px;
  height: 44px;
  color: #ffffff;
  font-size: 14.5px;
  font-weight: 800;
  letter-spacing: 0.5px;
  cursor: pointer;
  box-shadow: 0 3px 10px rgba(56, 130, 229, 0.4);
  transition: transform 0.15s, opacity 0.15s;
}

.btn-replay:active {
  transform: scale(0.97);
  opacity: 0.9;
}

.btn-new-bet {
  background: #000000; /* Exact solid black from Image 3 */
  border: 1.5px solid #ffffff; /* Exact crisp white border from Image 3 */
  border-radius: 6px;
  height: 44px;
  color: #ffffff;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: background-color 0.15s, transform 0.15s;
}

.btn-new-bet:active {
  background: rgba(255, 255, 255, 0.15);
  transform: scale(0.97);
}

/* Touch halo on selected cell (Exact yellow-gold ring from Image 1) */
.cell.selected .cell-front {
  outline: 3px solid #facc15;
  outline-offset: 1px;
  box-shadow: 0 0 16px rgba(250, 204, 21, 0.85), inset 0 0 6px rgba(250, 204, 21, 0.6);
  filter: brightness(1.2);
}

.hidden {
  display: none !important;
}

