/* momen.evil */
/* 3RB Classic Backgammon / Tawla Style Engine v1 */

:root {
  --tawla-walnut: #2c1a0e;
  --tawla-walnut-dark: #190f07;
  --tawla-walnut-light: #452a17;
  --tawla-mahogany: #5c1e0e;
  --tawla-pearl: #f4ede2;
  --tawla-pearl-border: #d5c7b3;
  --tawla-brass: #d4af37;
  --tawla-brass-glow: rgba(212, 175, 55, 0.45);
  --tawla-checker-white: #fdfaf5;
  --tawla-checker-white-rim: #d1c7b7;
  --tawla-checker-black: #1a1512;
  --tawla-checker-black-rim: #3a2e26;
  --tawla-highlight-glow: rgba(34, 197, 94, 0.65);
  --tawla-danger-glow: rgba(239, 68, 68, 0.7);
}

.tawla-workspace {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: calc(100vh - 70px);
  background: radial-gradient(circle at center, #1e130c 0%, #0d0704 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  overflow-x: hidden;
  overflow-y: auto;
  user-select: none;
  font-family: 'Outfit', 'Cairo', sans-serif;
  padding: 8px 12px;
  box-sizing: border-box;
}

/* TOP HUD */
.tawla-hud {
  width: 100%;
  max-width: 1080px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(28, 17, 10, 0.85);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(212, 175, 55, 0.3);
  border-radius: 12px;
  padding: 6px 16px;
  margin-bottom: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  box-sizing: border-box;
}

.tawla-player-badge {
  display: flex;
  align-items: center;
  gap: 12px;
}

.tawla-player-avatar-wrapper {
  position: relative;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2px solid var(--tawla-brass);
  overflow: hidden;
  box-shadow: 0 0 12px var(--tawla-brass-glow);
}

.tawla-player-avatar {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.tawla-checker-indicator {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.6);
}

.tawla-indicator-white {
  background: url('/assets/tawla/checker_white_3rb.png') no-repeat center center / cover;
  border: 1px solid #ffd700;
}

.tawla-indicator-black {
  background: url('/assets/tawla/checker_red_3rb.png') no-repeat center center / cover;
  border: 1px solid #ffd700;
}

.tawla-player-info {
  display: flex;
  flex-direction: column;
}

.tawla-player-name {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
}

.tawla-player-meta {
  font-size: 12px;
  color: #d1b89d;
  display: flex;
  gap: 8px;
}

.tawla-hud-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.tawla-turn-pill {
  padding: 6px 18px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.5px;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(212, 175, 55, 0.4);
  color: #f7dfa5;
  box-shadow: 0 0 14px rgba(212, 175, 55, 0.2);
  transition: all 0.3s ease;
}

.tawla-turn-pill.my-turn {
  background: linear-gradient(135deg, rgba(212, 175, 55, 0.3), rgba(180, 83, 9, 0.3));
  border-color: #f59e0b;
  color: #fff;
  box-shadow: 0 0 20px rgba(245, 158, 11, 0.5);
  animation: pulseGoldGlow 1.8s infinite;
}

@keyframes pulseGoldGlow {
  0%, 100% { box-shadow: 0 0 12px rgba(245, 158, 11, 0.4); }
  50% { box-shadow: 0 0 24px rgba(245, 158, 11, 0.8); }
}

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

/* MAIN BOARD CONTAINER (100% Mathematically locked to authentic 1376x768 Syrian walnut board photo) */
.tawla-board-outer {
  position: relative;
  width: 100%;
  max-width: min(1080px, calc((100vh - 240px) * 1.7916));
  max-height: calc(100vh - 240px);
  aspect-ratio: 1376 / 768;
  background: #25160d;
  border-radius: 12px;
  padding: 0;
  box-sizing: border-box;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.85);
  display: flex;
  justify-content: space-between;
  background-image: url('/assets/tawla/tawla_board_clean_3rb.jpg?v=20261026_super_clean_v7');
  background-size: 100% 100%;
  background-position: center;
  direction: ltr; /* Standard international & CrazyGames Backgammon layout: bear-off tray on the right! */
}

@media (max-height: 650px) {
  .tawla-workspace {
    padding: 4px 8px;
    gap: 4px;
  }
  .tawla-hud {
    padding: 4px 12px;
    margin-bottom: 2px;
  }
  .tawla-board-outer {
    max-height: calc(100vh - 215px);
    max-width: min(1080px, calc((100vh - 215px) * 1.7916));
    padding: 0;
  }
}

.tawla-board-overlay {
  display: none !important;
}

/* Board layout grid matching photo zones to 0.0px precision */
.tawla-tabletop {
  position: relative;
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: 20.71% 27.62% 3.34% 27.62% 20.71%; /* Left tray, Left board, Center Bar, Right board, Right tray */
  gap: 0;
  z-index: 2;
  direction: ltr;
  padding: 0;
  margin: 0;
}

.tawla-half-right {
  grid-column: 4;
}

.tawla-half {
  display: grid;
  grid-template-rows: 1fr 1fr;
  height: 100%;
  padding: 0;
}

.tawla-row {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  height: 100%;
  align-items: stretch;
}

.tawla-row-top {
  padding-top: 13.54%;
  box-sizing: border-box;
  align-items: flex-start;
}

.tawla-row-bottom {
  padding-bottom: 13.54%;
  box-sizing: border-box;
  align-items: flex-end;
}

/* POINT (TRIANGLE CONTAINER) */
.tawla-point {
  position: relative;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.2s ease;
  padding: 2px 0;
  box-sizing: border-box;
}

.tawla-row-top .tawla-point {
  justify-content: flex-start;
}

.tawla-row-bottom .tawla-point {
  justify-content: flex-end;
}

/* Synthetic triangle overlays disabled: board background photo already has authentic mother-of-pearl & mahogany inlay triangles */
.tawla-point::before,
.tawla-point-light::before,
.tawla-point-dark::before {
  display: none !important;
}

/* Point number label */
.tawla-point-num {
  position: absolute;
  font-size: 10px;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.35);
  z-index: 2;
  pointer-events: none;
}

.tawla-row-top .tawla-point-num {
  top: 4px;
}

.tawla-row-bottom .tawla-point-num {
  bottom: 4px;
}

/* Highlighted point for legal move */
.tawla-point.tawla-legal-target {
  filter: drop-shadow(0 0 10px rgba(34, 197, 94, 0.9));
}

.tawla-point.tawla-legal-target::after {
  content: '';
  position: absolute;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(34, 197, 94, 0.3);
  border: 2px dashed #4ade80;
  z-index: 6;
  animation: bounceRing 1.2s infinite;
}

.tawla-row-top .tawla-point.tawla-legal-target::after {
  bottom: 20%;
}

.tawla-row-bottom .tawla-point.tawla-legal-target::after {
  top: 20%;
}

@keyframes bounceRing {
  0%, 100% { transform: scale(0.9); opacity: 0.6; }
  50% { transform: scale(1.15); opacity: 1; }
}

.tawla-point.tawla-selected-source {
  background: rgba(212, 175, 55, 0.2);
  border-radius: 6px;
}

/* CHECKERS STACK */
.tawla-checkers-stack {
  position: relative;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 4;
}

.tawla-row-top .tawla-checkers-stack {
  justify-content: flex-start;
}

.tawla-row-bottom .tawla-checkers-stack {
  justify-content: flex-end;
}

/* CHECKER PIECE (Proportionally sized to point triangle base) */
.tawla-checker {
  position: relative;
  width: 86%;
  max-width: 44px;
  aspect-ratio: 1;
  height: auto;
  border-radius: 50%;
  margin-top: -38%; /* Proportional stack overlap */
  box-sizing: border-box;
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 800;
}

.tawla-checker:first-child {
  margin-top: 0;
}

/* White / Ivory Checker (3RB Branded High-Res) */
.tawla-checker-white {
  background: url('/assets/tawla/checker_white_3rb.png') no-repeat center center / contain;
  border: none;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.45);
}

.tawla-checker-white::after {
  display: none;
}

/* Red / Ruby Wood Checker (3RB Branded High-Res) */
.tawla-checker-black {
  background: url('/assets/tawla/checker_red_3rb.png') no-repeat center center / contain;
  border: none;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.55);
}

.tawla-checker-black::after {
  display: none;
}

.tawla-checker:hover {
  transform: translateY(-4px) scale(1.06);
}

.tawla-checker.tawla-active-movable {
  cursor: pointer;
  animation: movablePebble 1.6s infinite ease-in-out;
}

@keyframes movablePebble {
  0%, 100% { filter: drop-shadow(0 0 4px rgba(212, 175, 55, 0.6)); }
  50% { filter: drop-shadow(0 0 12px rgba(245, 158, 11, 0.95)); }
}

/* Overflow count indicator on top checker */
.tawla-stack-count {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  border-radius: 10px;
  padding: 2px 6px;
  font-size: 11px;
  font-weight: 900;
  border: 1px solid var(--tawla-brass);
  z-index: 5;
}

/* THE BAR (CENTER DIVIDER - 100% Transparent to show real brass hinges in photo) */
.tawla-bar {
  position: relative;
  height: 100%;
  background: transparent;
  border: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  padding: 13.54% 0;
  box-sizing: border-box;
  box-shadow: none;
  cursor: pointer;
}

.tawla-bar-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 80px;
}

.tawla-bar-title,
.tawla-bar-hinge {
  display: none !important; /* Authentic Damascus brass hinges already exist in photo */
}

/* BEAR-OFF TRAY (SIDE) MATCHING CRAZYGAMES BACKGAMMON & REAL DAMASCUS WALNUT TRAY */
.tawla-bearoff-tray {
  position: relative;
  height: 100%;
  background: transparent;
  border: none;
  border-radius: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: flex-end;
  padding-top: 13.54%;
  padding-bottom: 13.54%;
  padding-left: 0;
  padding-right: 0;
  box-sizing: border-box;
  box-shadow: none;
}

.tawla-tray-section {
  position: relative;
  width: 100%;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  box-sizing: border-box;
  cursor: pointer;
  transition: all 0.2s ease;
}

.tawla-tray-rack {
  position: relative;
  width: 44px;
  height: 100%;
  max-height: 220px;
  margin-right: calc(20% - 22px);
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
  padding: 0;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  overflow: visible;
}

#tawlaTrayWhite .tawla-tray-rack {
  margin-bottom: 22px;
}

#tawlaTrayBlack .tawla-tray-rack {
  margin-top: 22px;
}

/* 3D Real Checker in Side Tray Rack (حاجات الطاولة الأصلية) */
.tawla-tray-chip,
.tawla-tray-slot {
  position: relative;
  width: 44px;
  height: 18px;
  border-radius: 50% / 40%;
  margin-top: -8px;
  box-sizing: border-box;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.8), 
              inset 0 2px 3px rgba(255, 255, 255, 0.5),
              inset 0 -2px 3px rgba(0, 0, 0, 0.6);
  transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.2s ease;
  background-size: cover;
  background-position: center;
  flex-shrink: 0;
  cursor: pointer;
}

.tawla-tray-chip:first-child,
.tawla-tray-slot:first-child {
  margin-top: 0;
}

.tawla-tray-chip.chip-red,
.tawla-tray-slot.filled-red {
  background-color: #8b1515;
  background-image: url('/assets/tawla/checker_red_3rb.png');
  border: 1px solid #d4af37;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.6));
}

.tawla-tray-chip.chip-white,
.tawla-tray-slot.filled-white {
  background-color: #f7eedb;
  background-image: url('/assets/tawla/checker_white_3rb.png');
  border: 1px solid #d4af37;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
}

.tawla-tray-slot.empty {
  display: none;
}

.tawla-tray-chip:hover,
.tawla-tray-slot:hover {
  transform: scale(1.08) translateY(-2px);
  filter: brightness(1.15) drop-shadow(0 4px 10px rgba(212, 175, 55, 0.8));
}

/* Empty Tray Groove indicator when completely empty */
.tawla-tray-empty-hint {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(212, 175, 55, 0.25);
  font-size: 11px;
  font-weight: 800;
  text-align: center;
  user-select: none;
  pointer-events: none;
}

/* Real 3D Flying Checker Gliding across the Board */
.tawla-flying-checker {
  position: fixed;
  z-index: 10000;
  pointer-events: none;
  background-size: cover;
  background-position: center;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.85), 0 0 16px rgba(212, 175, 55, 0.7);
  transition: transform 320ms cubic-bezier(0.2, 0.9, 0.3, 1),
              width 320ms cubic-bezier(0.2, 0.9, 0.3, 1),
              height 320ms cubic-bezier(0.2, 0.9, 0.3, 1),
              border-radius 320ms ease,
              box-shadow 320ms ease,
              opacity 320ms ease;
  will-change: transform, width, height;
}

.tawla-flying-checker.fly-white {
  background-color: #f7eedb;
  background-image: url('/assets/tawla/checker_white_3rb.png');
  border: 1.5px solid #ffd700;
}

.tawla-flying-checker.fly-red {
  background-color: #8b1515;
  background-image: url('/assets/tawla/checker_red_3rb.png');
  border: 1.5px solid #ffd700;
}

/* Crisp pop bounce when checker lands on a point */
.tawla-deal-pop {
  animation: dealPopBounce 0.28s cubic-bezier(0.18, 0.89, 0.32, 1.28) forwards;
}

@keyframes dealPopBounce {
  0% {
    transform: scale(1.22);
    filter: drop-shadow(0 8px 16px rgba(212, 175, 55, 0.95)) brightness(1.2);
  }
  60% {
    transform: scale(0.94);
  }
  100% {
    transform: scale(1);
    filter: drop-shadow(0 3px 8px rgba(0, 0, 0, 0.6));
  }
}

/* Center Lightning Bolt Button */
.tawla-tray-center {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 4px 0;
  z-index: 5;
}

/* Center Roll Tile (Authentic CrazyGames Classic Backgammon but_dice.png) */
.tawla-lightning-btn {
  width: 48px;
  height: 48px;
  margin-right: calc(20% - 24px);
  background: transparent;
  border: none;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1), filter 0.2s ease;
  outline: none;
  position: relative;
}

.tawla-dice-tile-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.7));
  border-radius: 6px;
  pointer-events: none;
  transition: filter 0.2s ease;
}

.tawla-lightning-btn:hover {
  transform: scale(1.08);
}

.tawla-lightning-btn:hover .tawla-dice-tile-img {
  filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.85)) brightness(1.15);
}

.tawla-lightning-btn:active {
  transform: scale(0.92);
}

.tawla-lightning-btn.can-roll {
  animation: diceTilePulse 1.6s infinite ease-in-out;
}

@keyframes diceTilePulse {
  0%, 100% {
    transform: scale(1);
    filter: drop-shadow(0 3px 8px rgba(0, 0, 0, 0.6));
  }
  50% {
    transform: scale(1.12);
    filter: drop-shadow(0 0 16px rgba(255, 215, 0, 0.9)) brightness(1.2);
  }
}

/* Floating Skip Deal Button */
.tawla-skip-deal-btn {
  display: none !important;
}

/* Dealt Checker Pop Animation */
.tawla-checker.tawla-deal-pop {
  animation: checkerDealPop 0.22s cubic-bezier(0.18, 0.89, 0.32, 1.25) forwards;
}

@keyframes checkerDealPop {
  0% {
    transform: scale(0.3) translateY(-12px);
    opacity: 0.3;
  }
  70% {
    transform: scale(1.18) translateY(2px);
    opacity: 1;
  }
  100% {
    transform: scale(1) translateY(0);
    opacity: 1;
  }
}

.tawla-tray-section.tawla-legal-bearoff {
  background: rgba(34, 197, 94, 0.18);
  border-radius: 8px;
  box-shadow: 0 0 15px rgba(34, 197, 94, 0.6);
  animation: pulseGreenGlow 1.4s infinite;
}

@keyframes pulseGreenGlow {
  0%, 100% { box-shadow: 0 0 8px rgba(34, 197, 94, 0.4); }
  50% { box-shadow: 0 0 20px rgba(34, 197, 94, 0.85); }
}

/* DICE & CONTROLS TRAY (FLOATING IN CENTER BOARD) */
.tawla-controls-area {
  position: absolute;
  top: 50%;
  left: 34.5%; /* Centered in left inner board quadrant */
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  z-index: 10;
  pointer-events: auto;
}

.tawla-dice-pair {
  display: flex;
  align-items: center;
  gap: 16px;
  perspective: 900px;
  transform-style: preserve-3d;
}

.tawla-3d-die {
  position: relative;
  width: 52px;
  height: 52px;
  border-radius: 12px;
  display: grid;
  padding: 7px;
  box-sizing: border-box;
  transform-style: preserve-3d;
  transition: opacity 0.2s ease, filter 0.2s ease, transform 0.15s ease;
  cursor: pointer;
}

/* RED DIE (CrazyGames Classic Backgammon) */
.tawla-3d-die.tawla-die-red {
  background: radial-gradient(circle at 30% 30%, #ef4444 0%, #dc2626 40%, #991b1b 80%, #7f1d1d 100%);
  border: 1.5px solid #f87171;
  box-shadow: 0 8px 24px rgba(153, 27, 27, 0.55), 
              0 4px 12px rgba(0, 0, 0, 0.7), 
              inset 0 2px 4px rgba(255, 255, 255, 0.4), 
              inset 0 -2px 4px rgba(0, 0, 0, 0.5);
}

/* WHITE DIE (CrazyGames Classic Backgammon) */
.tawla-3d-die.tawla-die-white {
  background: radial-gradient(circle at 30% 30%, #ffffff 0%, #f8fafc 45%, #e2e8f0 80%, #cbd5e1 100%);
  border: 1.5px solid #ffffff;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.65), 
              inset 0 2px 4px rgba(255, 255, 255, 0.95), 
              inset 0 -2px 4px rgba(0, 0, 0, 0.25);
}

.tawla-3d-die.used-die {
  opacity: 0.35;
  filter: grayscale(0.8);
}

/* Realistic Human Dice Toss 3D Animations - Calm & Weighted like CrazyGames (1.25s) */
.tawla-3d-die.throwing-die-1 {
  animation: humanDiceThrowDie1 1.25s cubic-bezier(0.16, 0.9, 0.28, 1) forwards;
}

.tawla-3d-die.throwing-die-2 {
  animation: humanDiceThrowDie2 1.25s cubic-bezier(0.14, 0.88, 0.25, 1) forwards;
}

@keyframes humanDiceThrowDie1 {
  0% {
    transform: translate3d(-240px, -150px, 220px) rotateX(720deg) rotateY(540deg) rotateZ(360deg) scale(1.65);
    box-shadow: 30px 55px 70px rgba(0, 0, 0, 0.25);
    opacity: 0.7;
  }
  25% {
    transform: translate3d(-140px, -40px, 80px) rotateX(460deg) rotateY(320deg) rotateZ(220deg) scale(1.2);
    box-shadow: 15px 30px 45px rgba(0, 0, 0, 0.45);
    opacity: 1;
  }
  42% {
    /* First bounce impact */
    transform: translate3d(-70px, 22px, 0px) rotateX(260deg) rotateY(180deg) rotateZ(120deg) scale(0.95);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.85);
  }
  60% {
    /* Rebound in air */
    transform: translate3d(-32px, -36px, 45px) rotateX(120deg) rotateY(80deg) rotateZ(45deg) scale(1.1);
    box-shadow: 6px 18px 28px rgba(0, 0, 0, 0.4);
  }
  78% {
    /* Second bounce */
    transform: translate3d(-10px, 8px, 0px) rotateX(30deg) rotateY(15deg) rotateZ(-10deg) scale(0.97);
    box-shadow: 0 5px 12px rgba(0, 0, 0, 0.75);
  }
  90% {
    /* Micro roll / deceleration */
    transform: translate3d(-3px, -4px, 10px) rotateX(8deg) rotateY(-5deg) rotateZ(-6deg) scale(1.02);
    box-shadow: 2px 7px 15px rgba(0, 0, 0, 0.55);
  }
  100% {
    /* Final settled rest */
    transform: translate3d(0, 0, 0) rotateX(0deg) rotateY(0deg) rotateZ(-4deg) scale(1);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.65), inset 0 2px 4px rgba(255, 255, 255, 0.95);
  }
}

@keyframes humanDiceThrowDie2 {
  0% {
    transform: translate3d(220px, -170px, 240px) rotateX(-680deg) rotateY(720deg) rotateZ(-500deg) scale(1.7);
    box-shadow: -30px 60px 75px rgba(0, 0, 0, 0.22);
    opacity: 0.7;
  }
  26% {
    transform: translate3d(130px, -50px, 90px) rotateX(-420deg) rotateY(430deg) rotateZ(-300deg) scale(1.22);
    box-shadow: -16px 32px 48px rgba(0, 0, 0, 0.45);
    opacity: 1;
  }
  44% {
    /* First bounce impact */
    transform: translate3d(65px, 24px, 0px) rotateX(-220deg) rotateY(230deg) rotateZ(-150deg) scale(0.95);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.88);
  }
  62% {
    /* Rebound in air */
    transform: translate3d(28px, -40px, 50px) rotateX(-90deg) rotateY(90deg) rotateZ(-60deg) scale(1.1);
    box-shadow: -7px 18px 30px rgba(0, 0, 0, 0.4);
  }
  80% {
    /* Second bounce */
    transform: translate3d(8px, 8px, 0px) rotateX(-20deg) rotateY(10deg) rotateZ(12deg) scale(0.97);
    box-shadow: 0 5px 12px rgba(0, 0, 0, 0.75);
  }
  91% {
    /* Micro roll / deceleration */
    transform: translate3d(2px, -4px, 8px) rotateX(-5deg) rotateY(3deg) rotateZ(7deg) scale(1.02);
    box-shadow: -2px 7px 15px rgba(0, 0, 0, 0.55);
  }
  100% {
    /* Final settled rest */
    transform: translate3d(0, 0, 0) rotateX(0deg) rotateY(0deg) rotateZ(5deg) scale(1);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.65), inset 0 2px 4px rgba(255, 255, 255, 0.95);
  }
}

.tawla-die-pip {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  justify-self: center;
  align-self: center;
}

/* White pips on Red Die */
.tawla-die-pip.tawla-pip-white {
  background: radial-gradient(circle at 35% 35%, #ffffff 0%, #f1f5f9 60%, #cbd5e1 100%);
  box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.4), 0 1px 2px rgba(255, 255, 255, 0.6);
}

/* Black pips on White Die */
.tawla-die-pip.tawla-pip-black {
  background: radial-gradient(circle at 35% 35%, #334155 0%, #1e293b 60%, #090d16 100%);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.9), 0 1px 1px rgba(255, 255, 255, 0.3);
}

.tawla-pip-red {
  background: radial-gradient(circle at 35% 35%, #ef4444 0%, #991b1b 100%);
}

.tawla-roll-btn {
  display: none !important;
}

.tawla-roll-btn:hover {
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 8px 28px rgba(212, 175, 55, 0.7);
}

.tawla-roll-btn:active {
  transform: translateY(1px);
}

.tawla-pass-btn {
  background: rgba(40, 24, 15, 0.85);
  color: #d1b89d;
  font-size: 13px;
  font-weight: 700;
  border: 1px solid rgba(212, 175, 55, 0.4);
  border-radius: 18px;
  padding: 6px 16px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.tawla-pass-btn:hover {
  background: rgba(60, 36, 22, 0.95);
  color: #fff;
  border-color: #f59e0b;
}

/* VICTORY MODAL */
.tawla-victory-modal {
  position: absolute;
  inset: 0;
  background: rgba(10, 6, 3, 0.85);
  backdrop-filter: blur(14px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 50;
  animation: fadeInModal 0.4s ease-out;
}

@keyframes fadeInModal {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.tawla-victory-card {
  background: linear-gradient(145deg, #2b170c 0%, #150b06 100%);
  border: 2px solid var(--tawla-brass);
  border-radius: 20px;
  padding: 32px 48px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.9), 0 0 40px var(--tawla-brass-glow);
  max-width: 440px;
}

.tawla-victory-title {
  font-size: 28px;
  font-weight: 900;
  color: #ffd700;
  margin-bottom: 8px;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.6);
}

.tawla-victory-type {
  font-size: 16px;
  font-weight: 700;
  color: #f3ede2;
  margin-bottom: 20px;
}

.tawla-badge-gammon {
  color: #f59e0b;
  border: 1px solid #f59e0b;
  padding: 4px 12px;
  border-radius: 12px;
  background: rgba(245, 158, 11, 0.15);
}

.tawla-victory-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 3px solid var(--tawla-brass);
  box-shadow: 0 0 20px var(--tawla-brass-glow);
  margin-bottom: 14px;
}

.tawla-close-btn {
  background: linear-gradient(135deg, #d4af37, #b8860b);
  color: #1a0f07;
  font-weight: 800;
  font-size: 15px;
  border: none;
  border-radius: 24px;
  padding: 10px 32px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(212, 175, 55, 0.4);
  margin-top: 18px;
}

/* RESPONSIVE DESIGN */
@media (max-width: 900px) {
  .tawla-board-outer {
    aspect-ratio: auto;
    height: 480px;
    padding: 10px;
  }
  .tawla-checker {
    width: 32px;
    height: 32px;
    margin-top: -12px;
  }
  .tawla-checker::after {
    display: none;
  }
  .tawla-tabletop {
    grid-template-columns: 1fr 48px 1fr 56px;
  }
  .tawla-3d-die {
    width: 42px;
    height: 42px;
  }
}

/* Opening Checkers Deal Animation (توزيع القواشيش عند بدء اللعبة) */
.tawla-checker.tawla-dealing {
  animation: checkerDealSlide 0.38s cubic-bezier(0.18, 0.89, 0.32, 1) forwards;
}

@keyframes checkerDealSlide {
  0% {
    transform: translate(120px, -20px) scale(0.3);
    opacity: 0;
  }
  60% {
    transform: translate(-3px, 2px) scale(1.1);
    opacity: 1;
  }
  100% {
    transform: translate(0, 0) scale(1);
    opacity: 1;
  }
}

.tawla-tray-slot.dealing-out {
  animation: slotDealOut 0.25s ease-out forwards;
}

@keyframes slotDealOut {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.15) translateX(-8px); opacity: 0.8; }
  100% { transform: scale(0.4); opacity: 0; }
}

