:root {
  --board-bg: #8b5a2b; /* Wood color */
  --board-border: #5d3a1a;
  --point-dark: #cc3333; /* Red/Dark triangles */
  --point-light: #222; /* Black/Light triangles */
  --checker-white: #f0f0f0;
  --checker-black: #ff0000;
  --highlight: rgba(255, 255, 0, 0.6);
}

body {
  background: radial-gradient(circle, #2d3748, #1a202c);
  color: white;
  overflow: hidden; /* Prevent scrolling on game view */
}

.game-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100vh;
  padding: 10px;
}

header {
  display: flex;
  justify-content: space-between;
  width: 100%;
  max-width: 800px;
  margin-bottom: 10px;
  align-items: center;
}

.back-btn {
  color: white;
  text-decoration: none;
  font-weight: bold;
  background: rgba(255, 255, 255, 0.1);
  padding: 5px 15px;
  border-radius: 15px;
}

.game-area {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 600px; /* Adjust based on screen size */
  flex-grow: 1;
}

.player-info {
  display: flex;
  justify-content: space-between;
  background: rgba(0, 0, 0, 0.3);
  padding: 5px 15px;
  border-radius: 10px;
}

/* Board Styling */
.board {
  background-color: var(--board-bg);
  border: 15px solid var(--board-border);
  border-radius: 5px;
  display: grid;
  grid-template-columns: 1fr 40px 1fr; /* Left quadrant, Bar, Right quadrant */
  grid-template-rows: 1fr 1fr; /* Top half, Bottom half */
  gap: 0 0;
  width: 100%;
  aspect-ratio: 1.2 / 1; /* Typical board ratio */
  position: relative;
  box-shadow: inset 0 0 50px rgba(0, 0, 0, 0.5);
}

/* Quadrant Placement */
.quadrant.top-left { 
    grid-row: 1; 
    grid-column: 1; 
    border-right: 2px solid rgba(0,0,0,0.1); 
}
.quadrant.top-right { 
    grid-row: 1; 
    grid-column: 3; 
    border-left: 2px solid rgba(0,0,0,0.1); 
}
.quadrant.bottom-left { 
    grid-row: 2; 
    grid-column: 1; 
    border-right: 2px solid rgba(0,0,0,0.1); 
}
.quadrant.bottom-right { 
    grid-row: 2; 
    grid-column: 3; 
    border-left: 2px solid rgba(0,0,0,0.1); 
}

.quadrant {
  display: flex;
  justify-content: space-around; /* Distribute points evenly */
  padding: 0;
  position: relative;
  overflow: hidden;
}

/* Points (Triangles) */
.point {
  flex: 1;
  height: 48%; /* Adjust Visual Height */
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start; /* Stack checkers from base */
  transition: opacity 0.2s;
}

/* Rotate bottom points to face up */
.quadrant.bottom-left .point,
.quadrant.bottom-right .point {
  flex-direction: column-reverse; /* Stack from bottom */
  align-self: flex-end;
}
.quadrant.top-left .point,
.quadrant.top-right .point {
  align-self: flex-start;
}

/* Triangle visual */
.point::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
}

.quadrant.top-left .point::before,
.quadrant.top-right .point::before {
  clip-path: polygon(50% 100%, 0 0, 100% 0);
}

.quadrant.bottom-left .point::before,
.quadrant.bottom-right .point::before {
  clip-path: polygon(50% 0, 0 100%, 100% 100%);
}

.point.even::before {
  background-color: var(--point-dark);
}
.point.odd::before {
  background-color: var(--point-light);
}

/* Checkers */
.checker {
  width: 80%;
  aspect-ratio: 1;
  border-radius: 50%;
  margin: 1px 0;
  z-index: 1;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5);
  border: 2px solid rgba(0, 0, 0, 0.2);
}

.checker.white {
  background-color: var(--checker-white);
}
.checker.black {
  background-color: var(--checker-black);
}

.checker.pinned {
    border-color: gold; 
    box-shadow: 0 0 5px gold;
}
.checker.pinned::after {
    content: '🔒';
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1rem;
    filter: drop-shadow(0 0 2px black);
}

.bar {
  grid-row: 1 / span 2;
  grid-column: 2;
  background-color: var(--board-border);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  box-shadow: inset 0 0 10px rgba(0,0,0,0.5);
  visibility: hidden; /* Hide bar in Mahbouseh */
}

.bear-off {
  position: absolute;
  right: -40px;
  width: 30px;
  height: 45%;
  border: 2px dashed rgba(255, 255, 255, 0.3);
  border-radius: 5px;
}
.bear-off.top {
  top: 10px;
}
.bear-off.bottom {
  bottom: 10px;
}

/* Controls */
.controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;
  margin-top: 10px;
}

.dice-container {
  display: flex;
  gap: 20px;
}

.die {
  width: 50px;
  height: 50px;
  background: white;
  color: black;
  border-radius: 10px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 24px;
  font-weight: bold;
  box-shadow: 0 4px 0 #ccc;
}

.action-btn {
  padding: 10px 30px;
  font-size: 1.2rem;
  background: #e53e3e;
  color: white;
  border: none;
  border-radius: 25px;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.action-btn:hover {
  background: #c53030;
}
.action-btn:disabled {
    background: #555;
    cursor: not-allowed;
}

/* Selected & Valid Moves */
.point.selected::after {
    content: '';
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 20px; height: 20px;
    background: #00ff00;
    border-radius: 50%;
    box-shadow: 0 0 10px #00ff00;
    z-index: 10;
    pointer-events: none;
}
.point.selected .checker:last-child {
    box-shadow: 0 0 10px 2px #fff;
    border-color: #00ff00;
}

.bar.selected {
    box-shadow: inset 0 0 20px #00ff00;
}

.point.valid-move::before {
  /* Highlight the triangle background */
  background-color: rgba(255, 255, 0, 0.4) !important;
  box-shadow: inset 0 0 10px yellow;
}
.point.valid-move {
    cursor: pointer;
}
