/* Reset and base styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #333;
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  /* Prevent scrollbars in iframe */
}

.game-container {
  width: 100%;
  max-width: 800px;
  height: 100vh;
  min-height: 600px;
  max-height: 800px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background: #f5f5f5;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  overflow: hidden;
  box-sizing: border-box;
}

/* Header */
.game-header {
  background: linear-gradient(135deg, #8B4513 0%, #A0522D 100%);
  color: white;
  padding: 8px 12px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  box-sizing: border-box;
}

.game-title {
  font-size: 20px;
  font-weight: bold;
  margin: 0;
  flex-shrink: 0;
}

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

.btn {
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  min-height: 36px;
  touch-action: manipulation;
}

.btn-primary {
  background: #4CAF50;
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background: #45a049;
  transform: translateY(-1px);
}

.btn-secondary {
  background: #2196F3;
  color: white;
}

.btn-secondary:hover:not(:disabled) {
  background: #0b7dda;
  transform: translateY(-1px);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Hide Debug button by default - will be shown if debug-mode is enabled in config */
#debugBtn {
  display: none;
}

/* Show Debug button if debug-mode is enabled (set via JS) */
#debugBtn.debug-enabled {
  display: inline-block;
}

/* Hide Debug button when hidden by config */
.btn.hidden-by-config,
#debugBtn.hidden-by-config {
  display: none !important;
  visibility: hidden !important;
}

.mode-select {
  padding: 8px 12px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.2);
  color: white;
  font-size: 14px;
  cursor: pointer;
  min-height: 36px;
}

.mode-select option {
  background: #8B4513;
  color: white;
}

/* AI Difficulty selector */
.difficulty-select {
  padding: 8px 12px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.2);
  color: white;
  font-size: 14px;
  cursor: pointer;
  min-height: 36px;
  transition: background 0.2s;
}

.difficulty-select:hover {
  background: rgba(255, 255, 255, 0.3);
}

.difficulty-select option {
  background: #8B4513;
  color: white;
}

.difficulty-select option[value="easy"] {
  background: #4CAF50;
}

.difficulty-select option[value="medium"] {
  background: #FF9800;
}

.difficulty-select option[value="hard"] {
  background: #f44336;
}

/* Game info */
.game-info {
  padding: 8px 12px;
  background: #fff;
  display: flex;
  justify-content: flex-start;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  border-bottom: 2px solid #ddd;
  flex-shrink: 0;
  box-sizing: border-box;
  min-height: 52px;
  /* Fixed height to prevent layout jumps when message appears */
}

.current-player {
  display: flex;
  align-items: center;
  gap: 8px;
}

.player-label {
  font-weight: 500;
  color: #666;
}

.player-name {
  font-weight: bold;
  font-size: 16px;
  padding: 4px 12px;
  border-radius: 4px;
  background: #e3f2fd;
  color: #1976d2;
}

.player-name.black-turn {
  background: #263238;
  color: #fff;
}

/* Dice display - removed from game-info, now below board */
.dice-display {
  display: none;
  /* Hidden, using dice-display-below instead */
}

/* Dice display below board - closer to player (deprecated, using center display) */
.dice-display-below {
  display: none;
  /* Hidden, using dice-display-center instead */
}

/* Dice display in center bar */
.dice-display-center {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 4px 0;
  flex-shrink: 0;
  box-sizing: border-box;
  width: 100%;
  position: relative;
  z-index: 5;
}

.dice-container {
  display: flex;
  gap: 12px;
  align-items: center;
  position: relative;
}

.dice-container.clickable {
  cursor: pointer;
}

.dice-container.clickable::after {
  content: 'Click to roll';
  position: absolute;
  bottom: -24px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  font-weight: 500;
  color: #4CAF50;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}

.dice-display-below .dice-container.clickable::after {
  font-size: 12px;
  font-weight: 600;
  bottom: -26px;
  color: #2196F3;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8);
}

.dice-display-center .dice-container {
  gap: 10px;
}

.dice-display-center .dice-container.clickable::after {
  content: 'Click to roll';
  position: absolute;
  bottom: -20px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.9);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}

.dice-container.clickable:hover::after {
  opacity: 1;
}

.die {
  width: 70px;
  height: 70px;
  background: linear-gradient(145deg, #ffffff 0%, #f0f0f0 100%);
  border: 3px solid #333;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0;
  position: relative;
  box-shadow:
    0 6px 12px rgba(0, 0, 0, 0.25),
    inset 0 2px 0 rgba(255, 255, 255, 0.9),
    inset 0 -2px 0 rgba(0, 0, 0, 0.15);
  flex-shrink: 0;
  transition: all 0.3s ease;
  transform-style: flat;
  /* Changed from preserve-3d to prevent double rendering */
}

/* Dice when displayed below board - compact size (deprecated) */
.dice-display-below .die {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  border-width: 2px;
}

/* Dice when displayed in center bar - improved size for better visibility */
.dice-display-center .die {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  border-width: 2px;
  box-shadow:
    0 4px 8px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    inset 0 -1px 0 rgba(0, 0, 0, 0.15);
}

.die.clickable {
  cursor: pointer;
  animation: dicePulse 2s ease-in-out infinite;
  position: relative;
}

.die.clickable::before {
  content: '🎲';
  position: absolute;
  font-size: 28px;
  opacity: 0.4;
  transition: opacity 0.3s;
  z-index: 1;
}

/* Used dice - visually distinct with scale, shift and grayscale */
.die.used {
  position: relative;
  transform: scale(0.85) translateY(2px);
  filter: grayscale(0.6) brightness(0.9);
  opacity: 0.7;
  transition: transform 0.3s ease, filter 0.3s ease, opacity 0.3s ease;
}

/* Checkmark overlay to indicate used */
.die.used::after {
  content: '✓';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 20px;
  font-weight: bold;
  color: rgba(76, 175, 80, 0.8);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  z-index: 10;
  pointer-events: none;
}

/* Subtle overlay */
.die.used::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(200, 200, 200, 0.3);
  border-radius: 6px;
  z-index: 5;
  pointer-events: none;
}

/* Keep dots visible but muted on used dice */
.die.used .die-dot {
  background: #555;
  opacity: 0.8;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.3);
}

/* Doubles glow effect - golden shimmer */
.die.doubles {
  animation: doublesGlow 1.5s ease-in-out infinite;
  border-color: #FFD700;
}

.die.doubles .die-dot {
  background: #8B4513;
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.4),
    0 0 4px rgba(255, 215, 0, 0.5);
}

@keyframes doublesGlow {

  0%,
  100% {
    box-shadow:
      0 4px 8px rgba(0, 0, 0, 0.3),
      0 0 10px rgba(255, 215, 0, 0.4),
      0 0 20px rgba(255, 215, 0, 0.2),
      inset 0 1px 0 rgba(255, 255, 255, 0.9);
    background: linear-gradient(145deg, #fffef0 0%, #fff8dc 50%, #ffefd5 100%);
  }

  50% {
    box-shadow:
      0 4px 12px rgba(0, 0, 0, 0.3),
      0 0 20px rgba(255, 215, 0, 0.6),
      0 0 35px rgba(255, 215, 0, 0.3),
      inset 0 1px 0 rgba(255, 255, 255, 0.9);
    background: linear-gradient(145deg, #fffff5 0%, #fffacd 50%, #ffefd5 100%);
  }
}

/* Disable doubles glow on used dice */
.die.doubles.used {
  animation: none;
  border-color: #999;
}

.die.doubles.used .die-dot {
  background: #555;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.3);
}

.dice-display-below .die.clickable::before {
  font-size: 26px;
  opacity: 0.5;
}

.dice-display-center .die.clickable::before {
  font-size: 24px;
  opacity: 0.5;
}

/* Ensure clickable emoji is hidden when die has value */
.die.has-value.clickable::before,
.die.has-value::before {
  content: none !important;
  display: none !important;
  opacity: 0 !important;
  visibility: hidden !important;
}

.die.clickable:hover {
  transform: translateY(-4px) scale(1.05);
  box-shadow:
    0 6px 12px rgba(76, 175, 80, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    inset 0 -1px 0 rgba(0, 0, 0, 0.1);
}

.die.clickable:hover::before {
  opacity: 0.5;
}

.die.clickable:active {
  transform: translateY(-2px) scale(0.98);
}

.die.has-value {
  /* Show dots instead of numbers */
  background: linear-gradient(145deg, #ffffff 0%, #f5f5f5 100%);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 6px;
  padding: 10px;
  box-sizing: border-box;
}

/* Hide clickable emoji when die has value */
.die.has-value::before {
  content: none !important;
  display: none !important;
}

.dice-display-below .die.has-value {
  gap: 3px;
  padding: 6px;
}

.dice-display-center .die.has-value {
  gap: 3px;
  padding: 6px;
}

.die-dot {
  width: 8px;
  height: 8px;
  background: #333;
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  margin: auto;
  position: relative;
  z-index: 6;
  /* Above the used overlay (z-index: 5) but below checkmark (z-index: 10) */
}

.dice-display-below .die-dot {
  width: 9px;
  height: 9px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.dice-display-center .die-dot {
  width: 8px;
  height: 8px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

/* 3D Dice container for perspective */
.dice-container {
  perspective: 400px;
  perspective-origin: center center;
}

.die {
  transform-style: preserve-3d;
}

.die.rolled {
  animation: diceRoll3D 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

@keyframes diceRoll3D {
  0% {
    transform: translateY(-60px) rotateX(0deg) rotateY(0deg) rotateZ(0deg) scale(0.8);
    opacity: 0.7;
    box-shadow: 0 30px 20px -10px rgba(0, 0, 0, 0.15);
  }

  15% {
    transform: translateY(-40px) rotateX(180deg) rotateY(90deg) rotateZ(45deg) scale(0.9);
    opacity: 0.85;
    box-shadow: 0 25px 18px -8px rgba(0, 0, 0, 0.2);
  }

  35% {
    transform: translateY(-15px) rotateX(360deg) rotateY(270deg) rotateZ(90deg) scale(1);
    opacity: 1;
    box-shadow: 0 15px 12px -5px rgba(0, 0, 0, 0.25);
  }

  50% {
    transform: translateY(0) rotateX(540deg) rotateY(360deg) rotateZ(0deg) scale(1.1);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.35);
  }

  65% {
    transform: translateY(-8px) rotateX(600deg) rotateY(400deg) rotateZ(-10deg) scale(1.05);
    box-shadow: 0 10px 10px -3px rgba(0, 0, 0, 0.25);
  }

  80% {
    transform: translateY(0) rotateX(680deg) rotateY(440deg) rotateZ(5deg) scale(1.02);
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.3);
  }

  90% {
    transform: translateY(-3px) rotateX(710deg) rotateY(355deg) rotateZ(-2deg) scale(1.01);
    box-shadow: 0 5px 8px -2px rgba(0, 0, 0, 0.28);
  }

  100% {
    transform: translateY(0) rotateX(720deg) rotateY(360deg) rotateZ(0deg) scale(1);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
  }
}

/* Ensure transform resets completely after animation */
.die:not(.rolled):not(.clickable):not(:hover) {
  transform: none !important;
}

@keyframes dicePulse {

  0%,
  100% {
    box-shadow:
      0 4px 8px rgba(0, 0, 0, 0.2),
      inset 0 1px 0 rgba(255, 255, 255, 0.8),
      inset 0 -1px 0 rgba(0, 0, 0, 0.1);
  }

  50% {
    box-shadow:
      0 4px 12px rgba(76, 175, 80, 0.4),
      inset 0 1px 0 rgba(255, 255, 255, 0.8),
      inset 0 -1px 0 rgba(0, 0, 0, 0.1);
  }
}

/* Shake animation for invalid moves */
.shake {
  animation: shake 0.4s cubic-bezier(.36, .07, .19, .97) both;
  transform: translate3d(0, 0, 0);
  backface-visibility: hidden;
  perspective: 1000px;
}

@keyframes shake {

  10%,
  90% {
    transform: translate3d(-1px, 0, 0);
  }

  20%,
  80% {
    transform: translate3d(2px, 0, 0);
  }

  30%,
  50%,
  70% {
    transform: translate3d(-4px, 0, 0);
  }

  40%,
  60% {
    transform: translate3d(4px, 0, 0);
  }
}

/* Board container */
.game-board-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 8px;
  overflow: hidden;
  min-height: 0;
  box-sizing: border-box;
}

.board-wrapper {
  position: relative;
  width: 100%;
  max-width: 100%;
  flex: 1;
  min-height: 0;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
}

/* Vertical Bar (part of each row, between 6 points on each side) */
.bar-vertical {
  width: 50px;
  min-width: 50px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(to right, #654321 0%, #8B4513 50%, #654321 100%);
  border-left: 3px solid #4A2C17;
  border-right: 3px solid #4A2C17;
  position: relative;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  flex-shrink: 0;
  padding: 4px;
}

.bar-top-section {
  border-bottom: 2px solid rgba(255, 255, 255, 0.2);
  justify-content: flex-start;
}

.bar-bottom-section {
  border-top: 2px solid rgba(255, 255, 255, 0.2);
  justify-content: flex-end;
}


.bar-bottom-section {
  border-top: 2px solid rgba(255, 255, 255, 0.2);
}


/* Hide bar labels/indicators for classic look */
.bar-label,
.bar-indicator {
  display: none;
}

/* Legacy bar styles for compatibility */
.bar {
  height: 60px;
  background: linear-gradient(to bottom, #654321 0%, #8B4513 50%, #654321 100%);
  border: 3px solid #4A2C17;
  border-radius: 8px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  position: relative;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.bar-black {
  margin-bottom: 0;
  margin-top: 8px;
}

.bar-label {
  font-size: 10px;
  font-weight: bold;
  color: white;
  text-transform: uppercase;
  writing-mode: horizontal-tb;
  text-align: center;
  margin-bottom: 4px;
}

.bar-section .bar-label {
  font-size: 9px;
  margin-bottom: 2px;
}

.bar-indicator {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #DC143C;
  color: white;
  font-weight: bold;
  font-size: 14px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid white;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  z-index: 10;
  opacity: 0;
  transition: opacity 0.3s;
}

.bar-section .bar-indicator {
  position: relative;
  top: auto;
  left: auto;
  transform: none;
  margin-top: 4px;
  font-size: 12px;
  width: 20px;
  height: 20px;
}

.bar-indicator.show {
  opacity: 1;
}

.bar-checkers {
  display: flex;
  gap: 2px;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  margin-top: 4px;
}

.bar-section .bar-checkers {
  flex-direction: column;
  gap: 2px;
}

/* Main board - Horizontal layout: 2 rows of 12 points each */
.board {
  background:
    repeating-linear-gradient(90deg,
      rgba(210, 180, 140, 0.3) 0px,
      rgba(210, 180, 140, 0.3) 2px,
      rgba(139, 69, 19, 0.2) 2px,
      rgba(139, 69, 19, 0.2) 4px),
    linear-gradient(135deg, #D4A574 0%, #C19A6B 50%, #B8860B 100%);
  border: 3px solid #654321;
  border-radius: 6px;
  padding: 0;
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  position: relative;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.2);
  box-sizing: border-box;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  /* Clip content to border-radius */
}

/* Board rows (top and bottom) - each row has 12 points: 6 | BAR | 6 */
.board-row {
  display: flex;
  flex: 1;
  flex-direction: row;
  /* Points arranged horizontally */
  gap: 2px;
  min-height: 0;
  align-items: stretch;
  width: 100%;
  padding: 0 6px;
  box-sizing: border-box;
}

.board-row-top {
  margin-bottom: 2px;
}

.board-row-bottom {
  margin-top: 2px;
}

/* Center bar section between board rows - contains dice */
.board-center-bar {
  display: flex;
  flex-direction: row;
  width: 100%;
  gap: 2px;
  margin: 2px 0;
  padding: 0 6px;
  flex-shrink: 0;
  align-items: stretch;
  min-height: 60px;
  box-sizing: border-box;
}

/* Empty points sections for alignment */
.points-empty {
  flex: 1;
  min-width: 0;
  /* Invisible but maintains layout */
}

.board-center-bar .bar-vertical {
  margin: 0;
}

/* Center bar section - contains dice */
.bar-center-section {
  border-top: 2px solid rgba(255, 255, 255, 0.2);
  border-bottom: 2px solid rgba(255, 255, 255, 0.2);
  justify-content: center;
  min-height: 60px;
}

/* Points sections (left and right of bar) - each section has 6 points */
.points-section {
  display: flex;
  flex: 1;
  gap: 2px;
  min-width: 0;
}

/* Points sections - styles applied via flex layout in parent .points-section */

/* Board header - combined bear-off and home label */
.board-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: rgba(139, 69, 19, 0.3);
  flex-shrink: 0;
  box-sizing: border-box;
  min-height: 40px;
}

.board-header-top {
  border-radius: 6px 6px 0 0;
  border-bottom: 2px solid #8B4513;
}

.board-header-bottom {
  border-radius: 0 0 6px 6px;
  border-top: 2px solid #8B4513;
}

/* Inline bear-off area within board header */
.bear-off-inline {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  background: rgba(101, 67, 33, 0.4);
  border-radius: 4px;
  min-width: 80px;
}

.bear-off-inline-label {
  font-size: 10px;
  font-weight: bold;
  color: rgba(255, 255, 255, 0.7);
  text-transform: uppercase;
}

.bear-off-checkers {
  display: flex;
  gap: 2px;
  flex-wrap: nowrap;
  max-width: 150px;
  overflow: hidden;
}

.bear-off-inline .checker {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.bear-off-count {
  font-size: 12px;
  font-weight: bold;
  color: white;
  min-width: 20px;
  text-align: center;
}

/* Spacer to push home label to the right */
.header-spacer {
  flex: 1;
}

/* Home label */
.home-label {
  font-size: 12px;
  font-weight: bold;
  color: white;
  text-transform: uppercase;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
  padding: 4px 8px;
  background: rgba(139, 69, 19, 0.3);
  border-radius: 4px;
}

/* Legacy classes for compatibility */
.home-labels {
  display: none;
  /* Hide old home-labels if any remain */
}

.home-black-label-top {
  text-align: right;
  /* Black's home is on the right (points 19-24, top right) */
}

/* Individual point */
.point {
  flex: 1;
  position: relative;
  cursor: pointer;
  transition: all 0.2s;
  min-width: 0;
  height: 100%;
}

.point-triangle {
  width: 100%;
  height: 100%;
  position: relative;
}

/* Triangle orientation (classic): all point TOWARD the bar/center
   - Top row: point DOWN (vertex at bottom, base at top)
   - Bottom row: point UP (vertex at top, base at bottom)
*/

/* Top row: ALL triangles point DOWN (toward bar) */
.board-row-top .point-triangle {
  clip-path: polygon(50% 100%, 0% 0%, 100% 0%);
}

/* Bottom row: ALL triangles point UP (toward bar) */
.board-row-bottom .point-triangle {
  clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
}

/* Alternating colors */
/* Alternating colors using robust JS-assigned classes */
/* Odd Points (1, 3, 5... 13): DARK */
.point-type-odd .point-triangle {
  background: #8B4513;
  border: 1px solid #654321;
}

/* Even Points (2, 4, 6... 12): LIGHT */
.point-type-even .point-triangle {
  background: #F5DEB3;
  border: 1px solid #D2B48C;
}

.point-checkers {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 4px;
  pointer-events: none;
  overflow: visible;
  z-index: 5;
}

/* Debug: Point number labels */
.point-number-label {
  position: absolute;
  top: 2px;
  left: 2px;
  font-size: 10px;
  font-weight: bold;
  color: rgba(0, 0, 0, 0.6);
  background: rgba(255, 255, 255, 0.8);
  padding: 2px 4px;
  border-radius: 3px;
  z-index: 20;
  pointer-events: none;
  display: none;
  border: 1px solid rgba(0, 0, 0, 0.3);
}

.debug-mode .point-number-label {
  display: block;
}

/* Bottom row: show label at bottom */
.board-row-bottom .point-number-label {
  top: auto;
  bottom: 2px;
}

/* Checkers placement: at the BASE (wide edge) of each triangle, NOT at the vertex */
/* Standard Backgammon: checkers stack from the board edge (base) toward the center (tip) */
/* Top row: triangles point DOWN (vertex at bottom, base at top), so checkers at top (base) */
.board-row-top .point-checkers {
  justify-content: flex-start;
}

/* Bottom row: triangles point UP (vertex at top, base at bottom), so checkers at bottom (base) */
.board-row-bottom .point-checkers {
  justify-content: flex-start;
  /* Start from bottom because of column-reverse */
  flex-direction: column-reverse;
  /* Stack from bottom to top (Index 0 at Bottom, Index N at Top) */
  /* This matches the logical index order for selection: 
     - Index 0 (Base) is physically at Bottom
     - Index N (Tip) is physically at Top
     - Selection logic highlights Index N (Tip) correctly now
  */
}

/* Selected point - no outline, only checker is highlighted */
.point.selectable {
  outline: none !important;
  border: none !important;
  box-shadow: none !important;
}

/* Legal move targets - blue outline (MUST be blue, not green) */
.point.legal-move,
div.point.legal-move,
[data-point].legal-move,
.point[data-point].legal-move {
  outline: 3px solid #2196F3 !important;
  outline-color: #2196F3 !important;
  outline-style: solid !important;
  outline-width: 3px !important;
  outline-offset: -3px !important;
  animation: pulse 1s infinite;
  border: none !important;
  box-shadow: none !important;
}

/* Ensure legal-move overrides selectable when both are present */
.point.selectable.legal-move,
.point.legal-move.selectable,
div.point.selectable.legal-move,
div.point.legal-move.selectable {
  outline: 3px solid #2196F3 !important;
  outline-color: #2196F3 !important;
  outline-style: solid !important;
  outline-width: 3px !important;
  outline-offset: -3px !important;
  border: none !important;
  box-shadow: none !important;
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.7;
  }
}

.point.advice-target {
  outline: 3px solid #FF9800;
  outline-offset: -3px;
  animation: advicePulse 1.5s infinite;
}

.bar-vertical.advice-target,
.bear-off-inline.advice-target {
  outline: 3px solid #FF9800;
  outline-offset: -3px;
  animation: advicePulse 1.5s infinite;
}

/* Movable bar hint - blinking highlight when bar has movable checkers */
.bar-vertical.movable-bar-hint {
  outline: 3px solid #2196F3;
  outline-offset: -3px;
  animation: movableBarBlink 1s ease-in-out infinite;
  box-shadow:
    0 0 16px rgba(33, 150, 243, 0.8),
    0 2px 6px rgba(0, 0, 0, 0.3);
}

@keyframes movableBarBlink {

  0%,
  100% {
    outline-color: #2196F3;
    box-shadow:
      0 0 16px rgba(33, 150, 243, 0.8),
      0 2px 6px rgba(0, 0, 0, 0.3);
  }

  50% {
    outline-color: #42A5F5;
    box-shadow:
      0 0 24px rgba(33, 150, 243, 1),
      0 2px 6px rgba(0, 0, 0, 0.3);
  }
}

.bear-off-inline.legal-move {
  outline: 3px solid #2196F3;
  outline-offset: -3px;
  animation: pulse 1s infinite;
}

@keyframes advicePulse {

  0%,
  100% {
    outline-color: #FF9800;
  }

  50% {
    outline-color: #FFC107;
  }
}

/* Checkers */
.checker {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid #333;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4), inset 0 1px 2px rgba(255, 255, 255, 0.3);
  pointer-events: auto;
  touch-action: manipulation;
  flex-shrink: 0;
  display: block;
}

.checker.white {
  background: radial-gradient(circle at 30% 30%, #fff 0%, #f5f5f5 50%, #e0e0e0 100%);
  border-color: #999;
}

.checker.black {
  background: radial-gradient(circle at 30% 30%, #2c2c2c 0%, #1a1a1a 50%, #0a0a0a 100%);
  border-color: #000;
}

.checker.selected {
  transform: scale(1.25);
  box-shadow: 0 0 16px rgba(76, 175, 80, 1), 0 0 8px rgba(76, 175, 80, 0.6);
  z-index: 10;
  border: 3px solid #4CAF50;
  animation: selectedPulse 1.5s ease-in-out infinite;
}

@keyframes selectedPulse {

  0%,
  100% {
    box-shadow: 0 0 16px rgba(76, 175, 80, 1), 0 0 8px rgba(76, 175, 80, 0.6);
  }

  50% {
    box-shadow: 0 0 20px rgba(76, 175, 80, 1), 0 0 12px rgba(76, 175, 80, 0.8);
  }
}

.checker.moving {
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 100;
}

/* AI move animation - floating checker that moves across the board */
.checker.ai-moving {
  position: absolute !important;
  z-index: 1000 !important;
  pointer-events: none;
  box-shadow:
    0 8px 25px rgba(0, 0, 0, 0.5),
    0 0 20px rgba(255, 193, 7, 0.6),
    inset 0 1px 2px rgba(255, 255, 255, 0.3);
  animation: aiMoveGlow 0.4s ease-out;
}

.checker.ai-moving.black {
  box-shadow:
    0 8px 25px rgba(0, 0, 0, 0.6),
    0 0 20px rgba(244, 67, 54, 0.5),
    inset 0 1px 2px rgba(255, 255, 255, 0.2);
}

@keyframes aiMoveGlow {
  0% {
    transform: translate(-50%, -50%) scale(1);
    filter: brightness(1);
  }

  50% {
    transform: translate(-50%, -50%) scale(1.15);
    filter: brightness(1.2);
  }

  100% {
    transform: translate(-50%, -50%) scale(1.1);
    filter: brightness(1);
  }
}

/* Player move animation - smooth checker movement */
.checker.player-moving {
  position: absolute !important;
  z-index: 1000 !important;
  pointer-events: none;
  box-shadow:
    0 6px 20px rgba(0, 0, 0, 0.4),
    0 0 15px rgba(76, 175, 80, 0.6),
    inset 0 1px 2px rgba(255, 255, 255, 0.3);
  animation: playerMoveGlow 0.4s ease-out;
}

.checker.player-moving.white {
  box-shadow:
    0 6px 20px rgba(0, 0, 0, 0.4),
    0 0 18px rgba(76, 175, 80, 0.7),
    inset 0 1px 2px rgba(255, 255, 255, 0.5);
}

@keyframes playerMoveGlow {
  0% {
    transform: translate(-50%, -50%) scale(1);
    filter: brightness(1);
  }

  50% {
    transform: translate(-50%, -50%) scale(1.12);
    filter: brightness(1.15);
  }

  100% {
    transform: translate(-50%, -50%) scale(1.05);
    filter: brightness(1);
  }
}

.checker.advice-highlight {
  box-shadow: 0 0 12px rgba(255, 152, 0, 0.8);
  animation: checkerPulse 1.5s infinite;
}

@keyframes checkerPulse {

  0%,
  100% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.15);
  }
}

/* Movable hint - blinking highlight for checkers that can be moved */
.checker.movable-hint {
  box-shadow: 0 0 16px rgba(33, 150, 243, 1), 0 0 8px rgba(33, 150, 243, 0.8);
  animation: movableBlink 1s ease-in-out infinite;
  border-color: #2196F3;
  z-index: 15;
}

@keyframes movableBlink {

  0%,
  100% {
    box-shadow: 0 0 16px rgba(33, 150, 243, 1), 0 0 8px rgba(33, 150, 243, 0.8);
    transform: scale(1.1);
  }

  50% {

    /* ===== DRAG & DROP STYLES ===== */

    /* Checker being dragged */
    .checker.dragging {
      position: fixed !important;
      z-index: 10000 !important;
      pointer-events: none !important;
      cursor: grabbing !important;
      box-shadow:
        0 12px 35px rgba(0, 0, 0, 0.5),
        0 0 25px rgba(76, 175, 80, 0.7),
        inset 0 1px 3px rgba(255, 255, 255, 0.4);
      /* Disable ALL transitions and animations for instant response */
      transition: none !important;
      -webkit-transition: none !important;
      animation: none !important;
      will-change: left, top, transform;
      opacity: 0.95;
    }

    .checker.dragging.white {
      box-shadow:
        0 12px 35px rgba(0, 0, 0, 0.5),
        0 0 25px rgba(76, 175, 80, 0.8),
        inset 0 2px 4px rgba(255, 255, 255, 0.6);
    }

    .checker.dragging.black {
      box-shadow:
        0 12px 35px rgba(0, 0, 0, 0.6),
        0 0 25px rgba(244, 67, 54, 0.6),
        inset 0 1px 2px rgba(255, 255, 255, 0.2);
    }

    /* Ghost checker left at original position */
    .checker.drag-ghost {
      opacity: 0.3 !important;
      pointer-events: none !important;
      box-shadow: none !important;
    }

    /* Valid drop target highlight - CSS fallback (inline styles are primary) */
    .point.drop-target {
      position: relative;
      z-index: 10;
    }

    /* Drop target hover enhancement */
    .point.drop-target-hover {
      outline-color: #2E7D32 !important;
      box-shadow: inset 0 0 30px rgba(76, 175, 80, 0.6), 0 0 15px rgba(76, 175, 80, 0.5) !important;
    }

    /* Bear-off area as drop target - CSS fallback */
    .bear-off-inline.drop-target {
      outline: 3px solid #4CAF50 !important;
      outline-offset: 2px;
      background: rgba(76, 175, 80, 0.25) !important;
    }

    .bear-off-inline.drop-target-hover {
      outline-color: #2E7D32 !important;
      background: rgba(76, 175, 80, 0.4) !important;
    }

    /* Bar as drag source indicator */
    .bar-vertical.can-drag {
      cursor: grab;
    }

    .bar-vertical.can-drag .checker {
      cursor: grab;
    }

    /* Draggable checker cursor */
    .checker.can-drag {
      cursor: grab;
    }

    .checker.can-drag:active {
      cursor: grabbing;
    }

    /* Disable text selection during drag */
    .board.dragging-active,
    .board.dragging-active * {
      user-select: none !important;
      -webkit-user-select: none !important;
      -moz-user-select: none !important;
      -ms-user-select: none !important;
      cursor: grabbing !important;
    }

    /* Prevent text selection on labels - always */
    .board-header,
    .home-label,
    .bear-off-inline-label,
    .bear-off-count,
    .bar-label,
    .bar-indicator,
    .board-header *,
    .bear-off-inline * {
      user-select: none !important;
      -webkit-user-select: none !important;
      -moz-user-select: none !important;
      -ms-user-select: none !important;
      pointer-events: none;
    }

    /* But allow pointer events on the bear-off container itself */
    .bear-off-inline {
      pointer-events: auto;
    }

    /* Ensure bar checkers are clickable/draggable */
    .bar-vertical,
    .bar-checkers,
    .bar-checkers .checker {
      pointer-events: auto;
    }

    /* Prevent selection on all board content */
    .board {
      user-select: none;
      -webkit-user-select: none;
      -moz-user-select: none;
      -ms-user-select: none;
    }

    /* ===== END DRAG & DROP STYLES ===== */

    box-shadow: 0 0 24px rgba(33, 150, 243, 1),
    0 0 16px rgba(33, 150, 243, 1);
    transform: scale(1.2);
  }
}

/* Stacked checkers */
.checker-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  position: relative;
  z-index: 6;
  min-width: 28px;
}

/* Bottom row stacks need to be reversed so the first checker (index 0) 
   appears at the bottom (base) and the last checker (index N) appears at the top (tip) */
.board-row-bottom .checker-stack {
  flex-direction: column-reverse;
}

.checker-count {
  font-size: 10px;
  font-weight: bold;
  color: white;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
  background: rgba(0, 0, 0, 0.5);
  padding: 2px 4px;
  border-radius: 4px;
  margin-top: -2px;
}


/* Message display area - shows advice, reminders, events, and motivational messages
   Default style (yellow) is for advice messages, other types use modifier classes:
   .msg-reminder (blue), .msg-event (green), .msg-motivation (gold), 
   .msg-warning (orange), .msg-info (gray), .msg-achievement (gold sparkle),
   .msg-tip (purple), .msg-celebration (rainbow)
   Uses visibility instead of display to prevent layout jumps */
.advice-message {
  padding: 10px 16px;
  background: linear-gradient(135deg, #fff8e1 0%, #fff3cd 100%);
  border-left: 4px solid #ffc107;
  border-radius: 8px;
  color: #856404;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  position: relative;
  overflow: hidden;
  height: 36px;
  display: flex;
  /* Always in layout */
  align-items: center;
  flex-shrink: 0;
  box-sizing: border-box;
  flex: 1;
  min-width: 0;
  /* Allow flex item to shrink below content size */
  max-width: none;
  /* Remove max-width restriction */

  /* Hide using opacity and visibility to keep space reserved */
  opacity: 0;
  visibility: hidden;
  transform: translateX(-10px);
  transition: opacity 0.4s ease, visibility 0.4s ease, transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.advice-message.show {
  opacity: 1;
  visibility: visible;
  transform: translateX(0);
}

/* Emoji icon animation */
.advice-message.show::before {
  display: inline-block;
  animation: iconPulse 0.6s ease-out;
}

@keyframes iconPulse {
  0% {
    transform: scale(0.5);
    opacity: 0;
  }

  50% {
    transform: scale(1.3);
  }

  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Subtle shine effect on show */
.advice-message.show::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 50%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
  animation: messageShine 0.8s ease-out 0.2s;
}

@keyframes messageShine {
  0% {
    left: -100%;
  }

  100% {
    left: 200%;
  }
}

/* Make message clickable when it contains "Click to end turn" */
.advice-message.show.msg-warning {
  cursor: pointer;
  user-select: none;
}

.advice-message.show.msg-warning:hover {
  background: linear-gradient(135deg, #ffe69c 0%, #ffd54f 100%);
  transform: translateX(0) scale(1.02);
}

/* On mobile, advice message wraps below current player */
@media (max-width: 600px) {
  .advice-message {
    flex: 1 1 100%;
    margin-top: 8px;
    border-left: none;
    border-top: 3px solid #ffc107;
    border-radius: 0 0 8px 8px;
  }
}

/* ===== Message Types ===== */

/* Reminder - Blue, friendly nudge */
.advice-message.msg-reminder {
  background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
  border-left-color: #2196F3;
  color: #0d47a1;
}

/* Event - Green, game events */
.advice-message.msg-event {
  background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
  border-left-color: #4CAF50;
  color: #1b5e20;
}

/* Motivation - Gold, encouraging */
.advice-message.msg-motivation {
  background: linear-gradient(135deg, #fffde7 0%, #fff9c4 100%);
  border-left-color: #FFD700;
  color: #8B6914;
  font-weight: 600;
}

/* Warning - Orange, attention needed */
.advice-message.msg-warning {
  background: linear-gradient(135deg, #fff3e0 0%, #ffe0b2 100%);
  border-left-color: #FF9800;
  color: #e65100;
}

/* Info - Gray, neutral */
.advice-message.msg-info {
  background: linear-gradient(135deg, #fafafa 0%, #eeeeee 100%);
  border-left-color: #9E9E9E;
  color: #424242;
}

/* Tip - Purple, strategic advice */
.advice-message.msg-tip {
  background: linear-gradient(135deg, #f3e5f5 0%, #e1bee7 100%);
  border-left-color: #9C27B0;
  color: #6a1b9a;
}

/* Achievement - Gold with sparkle effect */
.advice-message.msg-achievement {
  background: linear-gradient(135deg, #fff8e1 0%, #ffecb3 50%, #ffe082 100%);
  border-left-color: #FFC107;
  color: #ff6f00;
  font-weight: 700;
  box-shadow: 0 4px 15px rgba(255, 193, 7, 0.4);
  animation: achievementGlow 1.5s ease-in-out infinite alternate;
}

@keyframes achievementGlow {
  0% {
    box-shadow: 0 4px 15px rgba(255, 193, 7, 0.4);
  }

  100% {
    box-shadow: 0 4px 25px rgba(255, 193, 7, 0.7), 0 0 10px rgba(255, 215, 0, 0.3);
  }
}

/* Celebration - Rainbow gradient for wins */
.advice-message.msg-celebration {
  background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 25%, #fecfef 50%, #a1c4fd 75%, #c2e9fb 100%);
  border-left: 4px solid transparent;
  border-image: linear-gradient(180deg, #ff6b6b, #feca57, #48dbfb, #ff9ff3) 1;
  color: #5f27cd;
  font-weight: 700;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.5);
  animation: celebrationPulse 0.8s ease-in-out infinite alternate;
}

@keyframes celebrationPulse {
  0% {
    transform: translateX(0) scale(1);
  }

  100% {
    transform: translateX(0) scale(1.02);
  }
}

/* Combo - Electric blue for streaks */
.advice-message.msg-combo {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-left-color: #5e35b1;
  color: #ffffff;
  font-weight: 600;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

/* Hit - Red flash for captures */
.advice-message.msg-hit {
  background: linear-gradient(135deg, #ffebee 0%, #ffcdd2 100%);
  border-left-color: #f44336;
  color: #c62828;
  font-weight: 600;
  animation: hitFlash 0.3s ease-out;
}

@keyframes hitFlash {
  0% {
    background: #ff5252;
    color: white;
  }

  100% {
    background: linear-gradient(135deg, #ffebee 0%, #ffcdd2 100%);
    color: #c62828;
  }
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
  padding: 20px;
}

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

.modal-content {
  background: white;
  border-radius: 12px;
  padding: 48px 40px 32px;
  max-width: 500px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  transform: scale(0.9);
  transition: transform 0.3s;
}

.modal-overlay.show .modal-content {
  transform: scale(1);
}

.modal-title {
  font-size: 24px;
  margin-bottom: 20px;
  margin-top: 20px;
  color: #333;
  text-align: center;
}

/* Game result message (win/lose) */
.game-result-message {
  font-size: 28px;
  font-weight: bold;
  text-align: center;
  padding: 16px;
  margin-bottom: 20px;
  border-radius: 8px;
  animation: resultFadeIn 0.5s ease-in;
}

.game-result-win {
  background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
  color: #2e7d32;
  border: 2px solid #4CAF50;
}

.game-result-lose {
  background: linear-gradient(135deg, #ffebee 0%, #ffcdd2 100%);
  color: #c62828;
  border: 2px solid #f44336;
}

@keyframes resultFadeIn {
  0% {
    opacity: 0;
    transform: translateY(-10px);
  }

  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-label {
  font-size: 14px;
  color: #666;
  font-weight: 500;
}

.stat-value {
  font-size: 18px;
  font-weight: bold;
  color: #333;
}

.modal-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
}

/* Responsive design for iframe 800x800 and mobile */
@media (max-width: 800px) {
  .game-container {
    max-height: 100vh;
    border-radius: 0;
  }

  .game-header {
    padding: 6px 10px;
  }

  .game-title {
    font-size: 18px;
  }

  .btn {
    font-size: 12px;
    padding: 6px 10px;
    min-height: 32px;
  }

  .game-info {
    padding: 6px 10px;
  }

  .game-board-container {
    padding: 6px;
  }

  .board {
    padding: 4px;
    border-left-width: 2px;
    border-right-width: 2px;
  }

  .bar-vertical {
    width: 40px;
    min-width: 40px;
    padding: 2px;
  }

  .bar-label {
    font-size: 9px;
  }

  .bar-indicator {
    font-size: 12px;
    width: 18px;
    height: 18px;
  }

  .checker {
    width: 22px;
    height: 22px;
  }

  .die {
    width: 35px;
    height: 35px;
    font-size: 18px;
  }

  .board-header {
    padding: 6px 8px;
    min-height: 35px;
  }

  .bear-off-inline {
    min-width: 60px;
    padding: 3px 6px;
  }

  .bear-off-inline .checker {
    width: 16px;
    height: 16px;
  }

  .bear-off-inline-label {
    font-size: 9px;
  }

  .home-label {
    font-size: 10px;
    padding: 3px 6px;
  }
}

@media (max-width: 600px) {
  .game-container {
    max-height: 100vh;
    border-radius: 0;
  }

  .game-header {
    flex-direction: column;
    align-items: stretch;
    padding: 6px 8px;
  }

  .game-title {
    text-align: center;
    font-size: 16px;
    margin-bottom: 4px;
  }

  .controls {
    justify-content: center;
    width: 100%;
  }

  .btn {
    flex: 1;
    min-width: 0;
    font-size: 11px;
    padding: 6px 8px;
    min-height: 32px;
  }

  .mode-select {
    font-size: 11px;
    padding: 6px 8px;
    min-height: 32px;
  }

  .game-info {
    flex-direction: column;
    align-items: stretch;
    padding: 6px 8px;
    gap: 6px;
  }

  .current-player {
    justify-content: center;
  }

  .player-name {
    font-size: 14px;
    padding: 3px 8px;
  }

  .dice-display {
    justify-content: center;
    width: 100%;
  }

  .die {
    width: 32px;
    height: 32px;
    font-size: 16px;
  }

  .board-wrapper {
    flex: 1;
    min-height: 0;
  }

  .bar-vertical {
    width: 35px;
    min-width: 35px;
  }

  .bar-label {
    font-size: 8px;
  }

  .bar-indicator {
    font-size: 10px;
    width: 16px;
    height: 16px;
  }

  .checker {
    width: 20px;
    height: 20px;
  }

  .checker-count {
    font-size: 8px;
  }

  .stats-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .modal-content {
    padding: 16px;
    max-width: 90vw;
  }

  .modal-buttons {
    flex-direction: column;
  }

  .modal-buttons .btn {
    width: 100%;
  }

  .board-header {
    padding: 4px 6px;
    min-height: 30px;
  }

  .bear-off-inline {
    min-width: 50px;
    padding: 2px 4px;
    gap: 3px;
  }

  .bear-off-inline .checker {
    width: 14px;
    height: 14px;
  }

  .bear-off-inline-label {
    font-size: 8px;
  }

  .bear-off-count {
    font-size: 10px;
  }

  .home-label {
    font-size: 9px;
    padding: 2px 4px;
  }

  .advice-message {
    font-size: 11px;
    padding: 6px 8px;
    height: 32px;
    /* Fixed height for mobile to prevent layout jumps */
  }
}

@media (max-width: 400px) {
  .checker {
    width: 18px;
    height: 18px;
  }

  .die {
    width: 28px;
    height: 28px;
    font-size: 14px;
  }

  .bar-vertical {
    width: 30px;
    min-width: 30px;
  }

  .bar-label {
    font-size: 7px;
  }
}

/* Touch-friendly adjustments */
@media (hover: none) and (pointer: coarse) {
  .btn {
    min-height: 40px;
    font-size: 14px;
  }

  .point {
    min-height: 35px;
  }

  .checker {
    min-width: 24px;
    min-height: 24px;
  }
}

/* Ensure no overflow in iframe */
html,
body {
  overflow: hidden;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
}

/* Optimize for 800x800 iframe */
@media (min-width: 800px) and (max-width: 800px) {
  .game-container {
    max-width: 800px;
    max-height: 800px;
  }
}

/* =========================================
   DOUBLING CUBE STYLES
   ========================================= */

.cube-container {
  position: absolute;
  top: 50%;
  left: 20px;
  /* Position on left side */
  transform: translateY(-50%);
  z-index: 50;
  pointer-events: none;
  /* Let clicks pass through if empty space */
}

.doubling-cube {
  width: 50px;
  height: 50px;
  background: linear-gradient(135deg, #f0f0f0 0%, #dcdcdc 100%);
  border: 1px solid #999;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: bold;
  color: #333;
  box-shadow:
    0 4px 6px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
  transition: all 0.3s ease;
  pointer-events: auto;
  cursor: help;
}

/* Orientation based on owner */
.doubling-cube.owner-white {
  background: #fff;
  color: #333;
  border-color: #666;
  transform: translateY(60px);
  /* Move towards white side (bottom) */
}

.doubling-cube.owner-black {
  background: #333;
  color: #fff;
  border-color: #000;
  transform: translateY(-60px);
  /* Move towards black side (top) */
}

/* =========================================
   MODAL STYLES
   ========================================= */

.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 1;
  transition: opacity 0.3s ease;
  backdrop-filter: blur(2px);
}

.modal.hidden {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}

.modal-content {
  background: white;
  padding: 24px;
  border-radius: 12px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  max-width: 400px;
  width: 90%;
  text-align: center;
  transform: translateY(0);
  transition: transform 0.3s ease;
}

.modal.hidden .modal-content {
  transform: translateY(-20px);
}

.modal h2 {
  margin-top: 0;
  color: #333;
  margin-bottom: 12px;
}

.modal p {
  color: #666;
  margin-bottom: 24px;
  line-height: 1.5;
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.btn.danger-btn {
  background: #f44336;
  color: white;
}

.btn.danger-btn:hover {
  background: #d32f2f;
}

/* Drop Target Highlights (Extracted from JS) */
.drop-target {
  outline: 3px solid #4CAF50;
  outline-offset: -3px;
  box-shadow: inset 0 0 25px rgba(76, 175, 80, 0.4), 0 0 10px rgba(76, 175, 80, 0.3);
  z-index: 10;
}

.drop-target-hover {
  outline: 4px solid #2E7D32 !important;
  box-shadow: inset 0 0 30px rgba(76, 175, 80, 0.6), 0 0 15px rgba(76, 175, 80, 0.6) !important;
}

/* Specific styles for bear-off area when valid target */
.bear-off-checkers.drop-target {
  outline: 3px solid #4CAF50;
  outline-offset: 2px;
  background-color: rgba(76, 175, 80, 0.25);
  box-shadow: 0 0 15px rgba(76, 175, 80, 0.6);
}

.bear-off-checkers.drop-target-hover {
  outline: 4px solid #2E7D32 !important;
  background-color: rgba(76, 175, 80, 0.4) !important;
  box-shadow: 0 0 20px rgba(76, 175, 80, 0.8) !important;
}

/* =========================================
   COMPACT STATS MODAL STYLES (REFINED)
   ========================================= */

.modal-content {
  padding: 16px;
  /* Significantly reduced */
  max-width: 400px;
}

.modal-title {
  font-size: 20px;
  margin-bottom: 12px;
  text-align: center;
}

.game-result-message {
  font-size: 22px;
  padding: 8px 12px;
  margin-bottom: 12px;
  border-radius: 6px;
  text-align: center;
}

.stats-comparison-table {
  display: flex;
  flex-direction: column;
  width: 100%;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.stats-header-row {
  display: flex;
  background: #f9fafb;
  padding: 8px 12px;
  border-bottom: 1px solid #e0e0e0;
  font-weight: 700;
  color: #555;
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.05em;
}

.stats-row {
  display: flex;
  padding: 6px 12px;
  /* Very compact rows */
  border-bottom: 1px solid #f0f0f0;
  align-items: center;
}

.stats-row:last-child {
  border-bottom: none;
}

.stats-row.highlight {
  background: #fff8e1;
  border-top: 1px solid #ffe0b2;
}

/* Column Widths */
.col-metric {
  flex: 2;
  text-align: left;
  font-weight: 600;
  color: #444;
  font-size: 13px;
}

.col-white,
.col-black {
  flex: 1;
  text-align: center;
}

.col-value {
  flex: 1;
  text-align: center;
  font-size: 14px;
  font-weight: 500;
}

/* Player Identity Colors in Table */
.col-white {
  color: #555;
}

.col-black {
  color: #222;
  font-weight: bold;
}

/* Footer Info */
.stats-footer-info {
  display: flex;
  justify-content: space-between;
  margin-bottom: 16px;
  padding: 0 4px;
  font-size: 11px;
  color: #888;
}

.stat-footer-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.stat-footer-item .value {
  font-weight: 700;
  color: #333;
  background: #f0f0f0;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 11px;
}

/* Responsive adjustments */
@media (max-width: 400px) {
  .modal-content {
    padding: 12px;
  }

  .stats-header-row,
  .stats-row {
    padding: 4px 8px;
  }

  .col-metric {
    font-size: 12px;
  }

  .col-value {
    font-size: 13px;
  }
}

/* =========================================
   PRO DESIGNER STATS MODAL
   ========================================= */

.modal-content {
  padding: 32px 24px;
  max-width: 420px;
  margin: auto;
  border-radius: 20px;
  box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.15), 0 10px 20px -10px rgba(0, 0, 0, 0.1);
  border: none;
  background: white;
  position: relative;
  overflow: visible;
  /* Allow content to breathe */
}

/* Elegant Title */
.modal-title {
  font-size: 16px;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: #888;
  margin-bottom: 24px;
  text-align: center;
  font-weight: 600;
}

/* Winner Banner as a Badge or Clean Text */
.game-result-message {
  font-size: 28px;
  padding: 0;
  margin-bottom: 32px;
  background: none;
  color: #222;
  text-align: center;
  font-weight: 800;
  letter-spacing: -0.5px;
}

/* Modern Layout Container */
.stats-modern {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 32px;
}

/* Header with Avatars */
.modern-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding: 0 16px;
}

.player-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 80px;
}

.avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
  border: 4px solid white;
}

.white-avatar {
  background: #e0e0e0;
}

.black-avatar {
  background: #333;
}

.p-name {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  color: #555;
  letter-spacing: 0.5px;
}

.metric-label-col {
  font-size: 10px;
  color: #ccc;
  font-weight: 700;
  margin-top: 20px;
  /* Align with names roughly */
}

/* Stat Rows: Clean, No Borders */
.modern-stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px;
  border-radius: 12px;
  transition: background 0.2s;
}

.modern-stat-row:hover {
  background: #f9f9f9;
}

.modern-stat-row.highlight {
  background: #fffbe6;
}

/* Subtle winner highlight */

.stat-val {
  font-size: 24px;
  /* Big numbers */
  font-weight: 800;
  width: 60px;
  font-family: 'Helvetica Neue', sans-serif;
  /* Clean sans */
}

.w-val {
  text-align: center;
  color: #444;
}

.b-val {
  text-align: center;
  color: #111;
}

.stat-lbl {
  font-size: 11px;
  text-transform: uppercase;
  color: #999;
  letter-spacing: 1px;
  font-weight: 600;
  text-align: center;
  flex: 1;
}

/* Footer: Minimal */
.stats-footer-info {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-bottom: 32px;
  font-size: 12px;
  color: #aaa;
}

.stat-footer-item {
  display: flex;
  gap: 6px;
  align-items: center;
}

.stat-footer-item .value {
  color: #555;
  font-weight: 700;
}

/* Buttons: Modern Pills */
.modal-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.btn {
  border-radius: 50px;
  /* Pill shape */
  font-weight: 600;
  letter-spacing: 0.5px;
  padding: 12px 24px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  border: none;
  transition: transform 0.1s, box-shadow 0.1s;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: #4CAF50;
  /* Green */
  color: white;
}

.btn-secondary {
  background: #2196F3;
  /* Blue */
  color: white;
  box-shadow: 0 4px 12px rgba(33, 150, 243, 0.3);
  border: none;
}

.btn-roll {
  background: #2196F3;
  /* Blue */
  color: white;
  box-shadow: 0 4px 12px rgba(33, 150, 243, 0.3);
}

/* Mobile Adjustments */
@media (max-width: 400px) {
  .modal-content {
    padding: 24px 16px;
    width: 90%;
  }
}

/* =========================================
   PREMIUM DASHBOARD STATS MODAL (FINAL)
   ========================================= */

#statsTitle {
  display: none !important;
}

.modal-content {
  padding: 0;
  width: 90%;
  max-width: 440px;
  margin: auto;
  border-radius: 24px;
  box-shadow: 0 40px 80px -20px rgba(0, 0, 0, 0.3), 0 20px 30px -15px rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.8);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  overflow: hidden;
  position: relative;
}

/* 1. Winner Banner */
.winner-banner {
  background: linear-gradient(135deg, #FFD700 0%, #FDB931 100%);
  /* Gold Gradient */
  padding: 24px 0 32px 0;
  text-align: center;
  color: #3e2723;
  clip-path: ellipse(150% 100% at 50% 0%);
  margin-bottom: -20px;
  /* Slight overlap */
  position: relative;
  z-index: 10;
}

.winner-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.trophy-icon {
  font-size: 42px;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.2));
  animation: popIn 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.winner-text {
  display: flex;
  flex-direction: column;
}

.w-label {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 2px;
  opacity: 0.7;
  margin-bottom: 2px;
}

.w-name {
  font-size: 32px;
  font-weight: 900;
  letter-spacing: -1px;
  line-height: 1;
}

/* 2. Visual Stats Container */
.stats-visual-container {
  display: none;
  /* TEMPORARY: User requested to hide stats */
  padding: 32px 32px 32px 32px;
  background: white;
  /* Ensure visibility */
}

.visual-legend {
  display: flex;
  justify-content: space-between;
  margin-bottom: 24px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #999;
  padding: 0;
  /* Align with values */
}

.leg-item.white {
  color: #8d6e63;
}

.leg-item.black {
  color: #3e2723;
}

/* 3. Visual Rows (Bar Charts) */
.visual-row {
  display: flex;
  align-items: center;
  margin-bottom: 28px;
  height: 24px;
  /* Fixed height for alignment */
  position: relative;
}

.center-label {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  font-size: 10px;
  font-weight: 800;
  color: #ccc;
  letter-spacing: 1px;
  z-index: 2;
  background: rgba(255, 255, 255, 0.9);
  padding: 2px 6px;
  border-radius: 4px;
  line-height: 1;
}

.bar-group {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  /* Ensure container has width for bars to grow into */
  width: calc(50% - 24px);
}

.bar-group.left {
  justify-content: space-between;
}

.bar-group.right {
  justify-content: space-between;
}

.stat-bar {
  height: 10px;
  /* Slim bars */
  background: #eee;
  border-radius: 6px;
  min-width: 4px;
  /* Always visible */
  transition: width 1s cubic-bezier(0.22, 1, 0.36, 1);
  width: 0%;
  /* Start at 0 for animation */
}

.white-bar {
  background: #d7ccc8;
  /* Soft White/Brown */
  box-shadow: 0 2px 4px rgba(141, 110, 99, 0.2);
}

.black-bar {
  background: #3e2723;
  /* Dark Brown/Black */
  box-shadow: 0 2px 4px rgba(62, 39, 35, 0.3);
}

.bar-val {
  font-size: 16px;
  font-weight: 800;
  color: #333;
  width: 30px;
  /* Fixed width for numbers */
  /* Fixed width for numbers */
  flex-shrink: 0;
  position: relative;
  z-index: 20;
}

.bar-group.left .bar-val {
  text-align: right;
}

.bar-group.right .bar-val {
  text-align: left;
}

/* Highlight Row (Wins) */
.visual-row.highlight-row .stat-bar {
  height: 14px;
}

.visual-row.highlight-row .center-label {
  color: #FFD700;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.1);
}

.visual-row.highlight-row .white-bar {
  background: #bcaaa4;
}

.visual-row.highlight-row .black-bar {
  background: #1a100e;
}


/* Footer & Buttons */
.stats-footer-info {
  display: none;
}

/* Hide old footer */

.modal-buttons {
  padding: 60px 32px 32px 32px;
  gap: 12px;
  justify-content: center;
  background: white;
}

.btn {
  border-radius: 14px;
  font-size: 14px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  font-weight: 700;
}

/* Animation */
@keyframes popIn {
  0% {
    transform: scale(0.5);
    opacity: 0;
  }

  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* AI Thinking Indicator */
.ai-thinking {
  display: inline-block;
  margin-left: 10px;
  font-size: 0.9em;
  color: #eebb44;
  /* Hardcoded gold if var not available, assuming var exists from memory or use safe hex */
  font-weight: 500;
  opacity: 1;
  transition: opacity 0.3s ease;
}

.ai-thinking.hidden {
  opacity: 0;
  pointer-events: none;
}

.ai-thinking .dots {
  animation: pulsedots 1.5s infinite;
}

@keyframes pulsedots {
  0% {
    opacity: 0.2;
  }

  50% {
    opacity: 1;
  }

  100% {
    opacity: 0.2;
  }
}