/* Backgammon Game CSS - Mobile First Responsive Design */

/* Root and Board Layout */
:root {
  --board-bg: #35654d;
  --point-light: #f5f5f5;
  --point-dark: #222;
  --checker1: #e74c3c;
  --checker2: #fff;
  --checker-border: #333;
  --bar-bg: #b8860b;
  --off-bg: #8b5c2a;
  --cube-bg: #fffbe6;
  --cube-border: #bfae5c;
  --highlight: #ffe066;
  --selected: #00bfff;
  --valid-move: #90ee90;
  --die-bg: #fff;
  --die-dot: #222;
}

body {
  margin: 0;
  /* font-family: 'Segoe UI', Arial, sans-serif; */
  /* background: linear-gradient(135deg, #6b4f1d 0%, #35654d 100%); */
  min-height: 100vh;
}

#game-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1em 0.5em;
  max-width: 100vw;
}

#ui-panel {
  width: 100%;
  max-width: 480px;
  margin-bottom: 1em;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.7em;
}

#dice-container {
  display: flex;
  gap: 0.5em;
}

.die {
  width: 2.2em;
  height: 2.2em;
  background: var(--die-bg);
  border: 2px solid #888;
  border-radius: 0.4em;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  font-size: 1.5em;
  box-shadow: 0 2px 6px #0002;
}

.die .dot {
  width: 0.4em;
  height: 0.4em;
  background: var(--die-dot);
  border-radius: 50%;
  position: absolute;
}

#doubling-cube {
  width: 2.2em;
  height: 2.2em;
  background: var(--cube-bg);
  border: 2px solid var(--cube-border);
  border-radius: 0.3em;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 1.3em;
  box-shadow: 0 2px 6px #0002;
  margin: 0.2em 0;
  cursor: pointer;
  user-select: none;
}

#action-buttons {
  display: flex;
  gap: 0.5em;
  flex-wrap: wrap;
}

#action-buttons button {
  padding: 0.5em 1em;
  font-size: 1em;
  border-radius: 0.3em;
  border: none;
  background: #35654d;
  color: #fff;
  font-weight: bold;
  cursor: pointer;
  transition: background 0.2s;
}

#action-buttons button:disabled {
  background: #888;
  cursor: not-allowed;
}

#action-buttons button:not(:disabled):hover {
  background: #4e8c6c;
}

#message-area {
  min-height: 2em;
  text-align: center;
  color: #fff;
  font-size: 1.1em;
  font-weight: 500;
  text-shadow: 0 1px 2px #0008;
}

/* Game Board */
#game-board {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  background: var(--board-bg);
  border-radius: 1em;
  box-shadow: 0 4px 24px #0005;
  padding: 0.5em;
  width: 100%;
  max-width: 480px;
  min-height: 340px;
  position: relative;
  overflow: hidden;
}

.board-half {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  flex: 1 1 0;
  gap: 0.1em;
  position: relative;
}

#bar {
  width: 2.2em;
  background: var(--bar-bg);
  border-radius: 0.5em;
  margin: 0 0.2em;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 90%;
  position: relative;
  z-index: 2;
}

.off-board {
  width: 2.2em;
  background: var(--off-bg);
  border-radius: 0.5em;
  margin: 0 0.2em;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  min-height: 90%;
  position: relative;
  z-index: 2;
  padding-bottom: 0.3em;
}

.point {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  position: relative;
  height: 100%;
  cursor: pointer;
  z-index: 1;
}

.point .triangle {
  width: 90%;
  height: 70%;
  position: absolute;
  left: 5%;
  bottom: 0;
  z-index: 0;
}

.point.top .triangle {
  top: 0;
  bottom: unset;
  transform: rotate(180deg);
}

.point .triangle.light {
  background: transparent;
  border-left: 50% solid transparent;
  border-right: 50% solid transparent;
  border-bottom: 100% solid var(--point-light);
  clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
}

.point .triangle.dark {
  background: transparent;
  border-left: 50% solid transparent;
  border-right: 50% solid transparent;
  border-bottom: 100% solid var(--point-dark);
  clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
}

.point.top .triangle.light,
.point.top .triangle.dark {
  border-bottom: none;
  border-top: 100% solid;
}

.point.top .triangle.light {
  border-top-color: var(--point-light);
}

.point.top .triangle.dark {
  border-top-color: var(--point-dark);
}

.point.valid-move .triangle {
  box-shadow: 0 0 10px 3px var(--valid-move);
}

.point.selected .triangle {
  box-shadow: 0 0 10px 3px var(--selected);
}

/* Checkers */
.checker {
  width: 1.7em;
  height: 1.7em;
  border-radius: 50%;
  border: 2px solid var(--checker-border);
  margin: 0.1em 0;
  box-shadow: 0 2px 6px #0003;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 2;
  cursor: pointer;
  transition: box-shadow 0.2s, border 0.2s;
}

.checker.player1 {
  background: var(--checker1);
  color: #fff;
}

.checker.player2 {
  background: var(--checker2);
  color: #e74c3c;
}

.checker.selected {
  box-shadow: 0 0 10px 3px var(--selected);
  border: 2px solid var(--selected);
}

.checker.hit {
  animation: hit-blink 0.5s;
}

@keyframes hit-blink {
  0% { box-shadow: 0 0 0 0 #fff; }
  50% { box-shadow: 0 0 10px 5px #fff; }
  100% { box-shadow: 0 0 0 0 #fff; }
}

/* Responsive Design */
@media (max-width: 600px) {
  #game-board {
    flex-direction: column;
    min-height: 420px;
    max-width: 98vw;
    padding: 0.2em;
  }
  .board-half {
    flex-direction: row;
    min-height: 5em;
    max-width: 100vw;
  }
  #bar, .off-board {
    min-height: 2.2em;
    min-width: 100%;
    flex-direction: row;
    margin: 0.1em 0;
    padding-bottom: 0;
  }
  #bar, .off-board {
    flex-direction: row;
    align-items: flex-end;
    justify-content: center;
  }
  #ui-panel {
    max-width: 98vw;
  }
}

/* Accessibility */
[aria-label] {
  outline: none;
}