:root {
  color-scheme: dark;
  --felt: #184f45;
  --felt-dark: #0f352f;
  --wood: #8b5a33;
  --wood-dark: #5e381d;
  --cream: #f7ead7;
  --ink: #18211f;
  --red: #b94c3e;
  --gold: #f4c86a;
  --blue: #58a7c8;
  --panel: #162321;
  --line: rgba(255, 255, 255, .16);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #101715;
  color: var(--cream);
  touch-action: manipulation;
}

button {
  font: inherit;
}

.game-shell {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: clamp(10px, 2vw, 22px);
}

.scorebar {
  display: grid;
  grid-template-columns: minmax(230px, 1fr) minmax(340px, 1.2fr);
  gap: 12px;
  align-items: stretch;
}

.brand,
.score-tile,
.dice-card,
.move-card,
.reset-action {
  background: color-mix(in srgb, var(--panel) 88%, white 12%);
  border: 1px solid var(--line);
  box-shadow: 0 18px 50px rgba(0, 0, 0, .26);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 92px;
  border-radius: 8px;
  padding: 12px 14px;
}

.goat-mark {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: var(--gold);
  color: #17201d;
  font-weight: 950;
  font-size: 30px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(24px, 3vw, 40px);
  line-height: 1;
  letter-spacing: 0;
}

.brand p {
  margin-top: 8px;
  color: rgba(247, 234, 215, .78);
  font-weight: 700;
}

.score-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.score-tile {
  min-height: 92px;
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.score-tile span,
.score-tile small {
  color: rgba(247, 234, 215, .76);
  font-weight: 800;
}

.score-tile strong {
  font-size: clamp(32px, 4vw, 54px);
  line-height: 1;
  color: white;
}

.score-tile strong i {
  color: rgba(255, 255, 255, .34);
  font-style: normal;
  padding: 0 4px;
}

.score-tile.player {
  border-color: rgba(244, 200, 106, .58);
}

.play-area {
  min-height: 0;
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 320px);
  gap: 14px;
}

.board-wrap {
  min-height: 420px;
  display: grid;
}

.board {
  position: relative;
  width: 100%;
  max-width: 1120px;
  aspect-ratio: 1.72 / 1;
  align-self: center;
  justify-self: center;
  display: grid;
  grid-template-rows: 42px 1fr 28px 1fr 42px;
  padding: 12px;
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(255,255,255,.08), transparent 12%, transparent 88%, rgba(0,0,0,.2)),
    var(--wood);
  border: 5px solid var(--wood-dark);
  box-shadow: 0 24px 70px rgba(0, 0, 0, .42), inset 0 0 0 3px rgba(255, 255, 255, .1);
  overflow: hidden;
}

.rail {
  display: grid;
  grid-template-columns: 1fr 86px;
  gap: 10px;
}

.rail.top {
  align-items: start;
}

.rail.bottom {
  align-items: end;
}

.bar-zone,
.bear-zone {
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 8px;
  background: rgba(0,0,0,.2);
  color: var(--cream);
  min-height: 32px;
  cursor: pointer;
}

.bar-zone {
  position: relative;
  background: linear-gradient(90deg, rgba(0,0,0,.08), rgba(255,255,255,.08), rgba(0,0,0,.08));
}

.bar-zone::before {
  content: "BAR";
  font-size: 12px;
  font-weight: 900;
  color: rgba(255,255,255,.56);
}

.bear-zone::before {
  content: "OFF";
  font-size: 12px;
  font-weight: 900;
  color: rgba(255,255,255,.56);
}

.points {
  position: relative;
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 2px;
  background: var(--felt);
  border-inline: 4px solid rgba(0,0,0,.16);
}

.top-row {
  border-radius: 8px 8px 0 0;
}

.bottom-row {
  border-radius: 0 0 8px 8px;
}

.point {
  position: relative;
  min-width: 0;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
  touch-action: manipulation;
}

.point::before {
  content: "";
  position: absolute;
  left: 5%;
  width: 90%;
  height: 88%;
  clip-path: polygon(50% 100%, 0 0, 100% 0);
  opacity: .95;
}

.top-row .point::before {
  top: 0;
}

.bottom-row .point::before {
  bottom: 0;
  transform: rotate(180deg);
}

.point:nth-child(odd)::before {
  background: var(--cream);
}

.point:nth-child(even)::before {
  background: var(--red);
}

.point.selected {
  outline: 4px solid var(--gold);
  outline-offset: -5px;
}

.point.legal,
.bar-zone.legal,
.bear-zone.legal {
  box-shadow: inset 0 0 0 4px var(--blue), 0 0 0 2px rgba(88, 167, 200, .35);
}

.point-number {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  color: rgba(255,255,255,.62);
  font-size: 11px;
  font-weight: 900;
  pointer-events: none;
}

.top-row .point-number {
  top: 4px;
}

.bottom-row .point-number {
  bottom: 4px;
}

.checker-stack {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  z-index: 3;
  pointer-events: none;
}

.top-row .checker-stack {
  flex-direction: column;
  justify-content: flex-start;
  padding-top: 8px;
}

.bottom-row .checker-stack {
  flex-direction: column-reverse;
  justify-content: flex-start;
  padding-bottom: 8px;
}

.checker {
  width: min(76%, 42px);
  aspect-ratio: 1;
  border-radius: 50%;
  margin: -2px auto;
  display: grid;
  place-items: center;
  color: transparent;
  border: 2px solid rgba(0,0,0,.3);
  box-shadow: inset 0 5px 10px rgba(255,255,255,.35), inset 0 -6px 12px rgba(0,0,0,.28), 0 3px 5px rgba(0,0,0,.3);
}

.checker.white {
  background: #f7ead7;
}

.checker.black {
  background: #c83232;
  border-color: rgba(90, 0, 0, .48);
}

.checker.extra {
  color: white;
  font-size: 13px;
  font-weight: 950;
}

.center-ridge {
  border-block: 3px solid rgba(255,255,255,.12);
  background: linear-gradient(90deg, transparent 0 48%, rgba(0,0,0,.2) 48% 52%, transparent 52% 100%), var(--felt-dark);
}

.control-panel {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.dice-card,
.move-card {
  border-radius: 8px;
  padding: 14px;
}

.turn-label {
  font-weight: 950;
  font-size: 18px;
  color: var(--gold);
}

.dice-tray {
  min-height: 92px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 12px 0;
}

.die {
  width: 58px;
  height: 58px;
  border: 0;
  border-radius: 8px;
  background: #fbf7ec;
  color: #151a18;
  box-shadow: inset 0 -5px 0 rgba(0,0,0,.12), 0 9px 18px rgba(0,0,0,.24);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  padding: 7px;
}

.die.used {
  opacity: .32;
  filter: grayscale(1);
}

.die.rolling {
  animation: tumble .72s cubic-bezier(.2,.8,.2,1);
}

.pip {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #151a18;
  place-self: center;
}

.primary-action,
.secondary-action,
.reset-action {
  width: 100%;
  min-height: 52px;
  border-radius: 8px;
  border: 0;
  font-weight: 950;
  cursor: pointer;
}

.primary-action {
  color: #17201d;
  background: var(--gold);
}

.secondary-action {
  margin-top: 8px;
  color: white;
  background: #287a6a;
}

.secondary-action:disabled,
.primary-action:disabled {
  opacity: .48;
  cursor: default;
}

.reset-action {
  color: var(--cream);
  background: #263330;
}

.move-card h2 {
  font-size: 18px;
  margin-bottom: 10px;
}

.move-list {
  min-height: 90px;
  max-height: 185px;
  overflow: auto;
  color: rgba(247, 234, 215, .82);
  line-height: 1.45;
  font-weight: 750;
}

.move-line {
  padding: 7px 0;
  border-top: 1px solid rgba(255,255,255,.1);
}

.ghost-checker {
  position: fixed;
  z-index: 20;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  pointer-events: none;
  border: 2px solid rgba(0,0,0,.3);
  box-shadow: inset 0 5px 10px rgba(255,255,255,.35), inset 0 -6px 12px rgba(0,0,0,.28), 0 10px 20px rgba(0,0,0,.36);
}

.ghost-checker.white {
  background: #f7ead7;
}

.ghost-checker.black {
  background: #c83232;
}

@keyframes tumble {
  0% { transform: translateY(-8px) rotate(0deg) scale(.8); }
  35% { transform: translateY(12px) rotate(210deg) scale(1.08); }
  70% { transform: translateY(-4px) rotate(410deg) scale(.94); }
  100% { transform: translateY(0) rotate(540deg) scale(1); }
}

@media (max-width: 920px) {
  .scorebar,
  .play-area {
    grid-template-columns: 1fr;
  }

  .control-panel {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  .reset-action {
    grid-column: 1 / -1;
  }
}

@media (max-width: 640px) {
  .game-shell {
    padding: 8px;
    gap: 8px;
  }

  .brand {
    min-height: 76px;
  }

  .goat-mark {
    width: 44px;
    height: 44px;
    font-size: 25px;
  }

  .score-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }

  .score-tile {
    min-height: 76px;
    padding: 8px;
  }

  .score-tile strong {
    font-size: 30px;
  }

  .score-tile small {
    font-size: 11px;
  }

  .board-wrap {
    min-height: auto;
  }

  .board {
    aspect-ratio: 1.05 / 1;
    grid-template-rows: 38px 1fr 24px 1fr 38px;
    padding: 8px;
    border-width: 4px;
  }

  .checker {
    width: min(82%, 30px);
    margin: -3px auto;
  }

  .point-number {
    font-size: 9px;
  }

  .control-panel {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .dice-card,
  .move-card {
    padding: 10px;
  }

  .dice-tray {
    min-height: 64px;
    margin: 8px 0;
  }

  .die {
    width: 48px;
    height: 48px;
  }

  .primary-action,
  .secondary-action,
  .reset-action {
    min-height: 50px;
  }

  .move-list {
    max-height: 110px;
  }
}
