body { gap: 16px; }

/* scoreboard chips (labels adapt to the mode in game.js) */
#score {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

/* mode + difficulty button groups (copied from connect-four) */
#mode,
#difficulty {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}
.mode-btn,
.diff-btn {
  padding: 8px 18px;
  font-size: 0.9rem;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: 0 2px 8px var(--shadow);
}
.mode-btn:hover,
.diff-btn:hover { opacity: 1; background: var(--surface-3); }
.mode-btn.active,
.diff-btn.active {
  background: var(--accent);
  color: var(--accent-text);
  border-color: transparent;
}
/* difficulty group is only shown in vs-CPU mode */
#difficulty[hidden] { display: none; }

/* ---------- dice + roll ---------- */
#diceBar {
  display: flex;
  align-items: center;
  gap: 14px;
}
#dice { display: flex; gap: 8px; min-height: 40px; align-items: center; }
.die {
  width: 40px;
  height: 40px;
  background: #f7f4ec;
  border-radius: 8px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  padding: 5px;
  box-shadow: 0 2px 6px var(--shadow), inset 0 -2px 4px rgba(0,0,0,0.18);
  border: 1px solid rgba(0,0,0,0.12);
}
.die.used { opacity: 0.32; }
.die .pip {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #2a2a2a;
  align-self: center;
  justify-self: center;
}
#roll { padding: 9px 22px; font-size: 0.95rem; }
#roll:disabled { opacity: 0.4; cursor: default; }

/* ---------- board ---------- */
#board {
  --board-felt: #2f7d4f;
  --board-felt-dark: #276a43;
  --frame: #6b4a2b;
  --frame-dark: #533619;
  --tri-light: #e9d9b8;
  --tri-dark: #b5824e;
  --checker-white: #f3efe6;
  --checker-black: #20242e;
}
:root[data-theme="dark"] #board {
  --board-felt: #1f5436;
  --board-felt-dark: #18452c;
  --frame: #4a3520;
  --frame-dark: #33240f;
  --tri-light: #d8c39a;
  --tri-dark: #9c6c3d;
  --checker-white: #e8e3d6;
  --checker-black: #161922;
}

.bg-wrap {
  display: flex;
  gap: 0;
  background: var(--frame);
  padding: 12px;
  border-radius: 12px;
  box-shadow: 0 12px 44px var(--shadow);
  border-bottom: 6px solid var(--frame-dark);
}

.bg-main {
  display: flex;
  flex-direction: column;
  background: var(--board-felt);
  border-radius: 6px;
  overflow: hidden;
}

.bg-row { display: flex; align-items: stretch; }
.bg-row .half { display: flex; flex: 1; }

/* one triangular point */
.point {
  position: relative;
  width: 38px;
  height: 168px;
  display: flex;
  cursor: default;
}
.point .tri {
  position: absolute;
  left: 0;
  width: 0;
  height: 0;
  border-left: 19px solid transparent;
  border-right: 19px solid transparent;
}
.point.top .tri {
  top: 0;
  border-top: 150px solid var(--tri-dark);
}
.point.bot .tri {
  bottom: 0;
  border-bottom: 150px solid var(--tri-dark);
}
.point.even.top .tri { border-top-color: var(--tri-light); }
.point.even.bot .tri { border-bottom-color: var(--tri-light); }

/* point index label */
.pt-label {
  position: absolute;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 0.6rem;
  color: rgba(255,255,255,0.55);
  pointer-events: none;
}
.point.top .pt-label { bottom: 2px; }
.point.bot .pt-label { top: 2px; }

/* checker stack inside a point */
.stack {
  position: absolute;
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 3px 0;
  z-index: 2;
}
.point.top .stack { top: 0; }
.point.bot .stack { bottom: 0; flex-direction: column-reverse; }

.checker {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  flex: none;
}
.checker.w {
  background: radial-gradient(circle at 35% 30%, #ffffff, var(--checker-white) 60%, #c9c2b0);
  border: 1px solid #b6ad96;
  box-shadow: inset 0 -2px 3px rgba(0,0,0,0.25);
}
.checker.b {
  background: radial-gradient(circle at 35% 30%, #4a4f5c, var(--checker-black) 65%, #05070c);
  border: 1px solid #000;
  box-shadow: inset 0 -2px 3px rgba(0,0,0,0.5);
}
.count-badge {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--accent);
  color: var(--accent-text);
  font-size: 0.72rem;
  font-weight: 700;
  border-radius: 10px;
  padding: 1px 6px;
  z-index: 5;
}

/* selectable / selected / target highlights */
.point.movable { cursor: pointer; }
.point.movable .tri { filter: brightness(1.12); }
.point.sel .tri { filter: brightness(1.3) saturate(1.3); }
.point.target::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.85;
  z-index: 4;
  cursor: pointer;
}

/* ---------- the bar (centre divider) ---------- */
.bar-slot {
  width: 34px;
  height: 168px;
  background: var(--frame-dark);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 6px 0;
  position: relative;
}
.bar-slot.bar-b { flex-direction: column; }
.bar-slot.bar-w { flex-direction: column-reverse; }
.bar-slot.movable { cursor: pointer; box-shadow: inset 0 0 0 2px var(--accent); }
.bar-slot.sel { box-shadow: inset 0 0 0 3px var(--accent); }

/* the bar columns sit inside each row, so give them the row height */
.bg-top .bar-slot { border-radius: 0 0 4px 4px; }
.bg-bot .bar-slot { border-radius: 4px 4px 0 0; }

/* ---------- bear-off trays ---------- */
.trays {
  display: flex;
  flex-direction: column;
  width: 64px;
  margin-left: 8px;
  gap: 4px;
}
.tray {
  flex: 1;
  background: var(--board-felt-dark);
  border-radius: 6px;
  border: 2px solid var(--frame-dark);
  padding: 6px 4px;
  display: flex;
  flex-direction: column;
  cursor: default;
}
.tray-b { justify-content: flex-start; }
.tray-w { justify-content: flex-end; }
.tray.target { box-shadow: inset 0 0 0 3px var(--accent); cursor: pointer; }
.tray-label {
  font-size: 0.6rem;
  color: rgba(255,255,255,0.7);
  text-align: center;
  margin-bottom: 3px;
}
.tray-stack { display: flex; flex-direction: column; gap: 2px; align-items: center; }
.off-bar {
  width: 46px;
  height: 9px;
  border-radius: 3px;
}
.off-bar.w { background: var(--checker-white); border: 1px solid #b6ad96; }
.off-bar.b { background: var(--checker-black); border: 1px solid #000; }

/* ---------- responsive: shrink the board on narrow screens ---------- */
@media (max-width: 640px) {
  .point { width: 26px; height: 132px; }
  .point .tri { border-left-width: 13px; border-right-width: 13px; }
  .point.top .tri { border-top-width: 116px; }
  .point.bot .tri { border-bottom-width: 116px; }
  .checker { width: 21px; height: 21px; }
  .bar-slot { width: 26px; }
  .bar-slot { height: 132px; }
  .trays { width: 46px; }
  .off-bar { width: 32px; height: 7px; }
  .pt-label { font-size: 0.5rem; }
}
@media (max-width: 420px) {
  .point { width: 21px; height: 116px; }
  .point .tri { border-left-width: 10.5px; border-right-width: 10.5px; }
  .point.top .tri { border-top-width: 102px; }
  .point.bot .tri { border-bottom-width: 102px; }
  .checker { width: 17px; height: 17px; }
  .bar-slot { width: 22px; }
  .bar-slot { height: 116px; }
  .trays { width: 38px; }
  .off-bar { width: 26px; }
}
