* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Trebuchet MS", "Lucida Sans Unicode", "Lucida Grande", sans-serif;
  background: #e4d7c5;
  color: #1c1b19;
}

.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 8px clamp(12px, 3vw, 24px);
}

.header {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-start;
}

.game-actions {
  align-self: stretch;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.header h1 {
  margin: 0;
  font-size: clamp(1.75rem, 3vw, 2.5rem);
  letter-spacing: 0.05em;
}

.confirm-end {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
}

button {
  border: 1px solid #3a3128;
  background: #f5eee3;
  padding: 10px 16px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.95rem;
}

button.primary {
  background: #7a4f2b;
  color: #fef6e9;
  border-color: #7a4f2b;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.new-game {
  align-self: flex-start;
  background: #e9ddca;
  color: #3b2b1f;
  border-color: #c7b29a;
}

.game-area {
  flex: 1;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 16px;
}

.board-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: flex-start;
}

.board-controls {
  display: flex;
  justify-content: flex-end;
  width: 100%;
}

.board-controls button {
  width: min(150px, 42vw);
}

.board-row {
  display: flex;
  align-items: flex-start;
  gap: var(--board-gap, 8px);
  width: fit-content;
  max-width: 100%;
}

.board {
  width: var(--board-width, 600px);
  height: var(--board-height, 900px);
  aspect-ratio: 14 / 9;
  max-height: calc(100vh - var(--ui-offset, 220px));
  background: #704c2d;
  border: 8px solid #3f2a1a;
  border-radius: 12px;
  padding: 6px;
  display: flex;
  gap: 0;
}

.quadrant {
  display: grid;
  grid-template-rows: 1fr 1fr;
  gap: 8px;
  width: calc(var(--point-width, 42px) * 6);
}

.row {
  display: grid;
  grid-template-columns: repeat(6, var(--point-width, 42px));
  gap: 3px;
}

.point {
  border-radius: 6px;
  display: flex;
  gap: 4px;
  align-items: center;
  position: relative;
  --point-color: #d7c09f;
  overflow: hidden;
}

.point.dark {
  --point-color: #9d7a56;
}

.point.top {
  flex-direction: column;
  justify-content: flex-start;
}

.point.bottom {
  flex-direction: column-reverse;
  justify-content: flex-start;
}

.point::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--point-color);
  clip-path: polygon(50% 100%, 0 0, 100% 0);
  border-radius: 4px;
  z-index: 0;
}

.point.bottom::before {
  clip-path: polygon(50% 0, 0 100%, 100% 100%);
}

.point-stack {
  position: absolute;
  inset: 0;
  pointer-events: none;
  width: 100%;
  overflow: visible;
}

.point.top .point-stack {
  top: 0;
  bottom: auto;
}

.point.bottom .point-stack {
  bottom: 0;
  top: auto;
}

.point.selected {
  outline: 3px solid #f2d76b;
  outline-offset: 2px;
}

.point.legal-dest {
  box-shadow: inset 0 0 0 3px rgba(242, 215, 107, 0.8);
}

.bar {
  background: #3b2a1c;
  border-radius: 8px;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.08);
  width: var(--bar-width, 84px);
  position: relative;
}

.bar-dice {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
  transition: top 0.3s ease, bottom 0.3s ease;
}

.bar[data-turn="white"] .bar-dice {
  bottom: 10px;
  top: auto;
}

.bar[data-turn="black"] .bar-dice {
  top: 10px;
  bottom: auto;
}

.checker {
  width: var(--checker-size, 42px);
  height: var(--checker-size, 42px);
  border-radius: 50%;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3), 0 2px 4px rgba(0, 0, 0, 0.2);
  z-index: 1;
  position: absolute;
  left: 50%;
  transform: translateX(calc(-50% + var(--checker-offset, 0px)));
  pointer-events: none;
}

.checker.white {
  background: #f7f1e6;
  border: 1px solid #cbbfae;
}

.checker.black {
  background: #2b2826;
  border: 1px solid #4b3f36;
}

.off-board {
  width: var(--off-width, 64px);
  min-width: var(--off-width, 64px);
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: stretch;
  justify-content: space-between;
}


.off-section {
  background: #5c3d25;
  border-radius: 12px;
  padding: 4px;
  display: grid;
  gap: 4px;
}

.off-stack {
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-items: center;
}

.off-stack .checker {
  width: min(24px, 5vw);
  height: min(24px, 5vw);
  position: static;
  transform: none;
}

.win-modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.55);
  z-index: 30;
}

.win-modal.hidden {
  display: none;
}

.win-content {
  background: #f6f1e7;
  border-radius: 14px;
  padding: 24px;
  text-align: center;
  min-width: 220px;
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.25);
}

.die {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  background: #f8f3ea;
  border: 2px solid #d0c2ad;
  display: grid;
  place-items: center;
  font-size: 1.8rem;
  font-weight: 700;
  color: #1c1b19;
  box-shadow: inset 0 4px 6px rgba(0, 0, 0, 0.2);
}

.die.used {
  background: #d8d8d8;
  color: #7a7a7a;
  border-color: #b0a7a0;
  box-shadow: inset 0 0 0 rgba(0, 0, 0, 0);
}

@media (max-width: 720px) {
  .board-row {
    gap: 8px;
  }
}
