*{
  box-sizing:border-box;
  margin:0;
  padding:0;
  font-family:"Space Grotesk",sans-serif;
}

html,
body{
  width:100%;
  min-height:100%;
  overflow-x:hidden;
  background:radial-gradient(circle at top,#3b2416 0%,#120904 48%,#050201 100%);
  color:white;
}

body{
  min-height:100vh;
}

button,
a{
  font-family:inherit;
}

.game-shell{
  min-height:100vh;
  display:flex;
  flex-direction:column;
}

.top-bar{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:16px;
  padding:16px 22px;
  background:rgba(0,0,0,.38);
  border-bottom:1px solid rgba(255,255,255,.1);
  position:sticky;
  top:0;
  z-index:50;
  backdrop-filter:blur(14px);
}

.top-left{
  display:flex;
  align-items:center;
  gap:28px;
  flex:1;
}

.title-wrap h1{
  font-size:clamp(1.55rem,3vw,2.6rem);
  letter-spacing:.12em;
}

.subtitle{
  opacity:.74;
  margin-top:6px;
}

.top-actions{
  display:flex;
  align-items:center;
  gap:10px;
}

.top-btn{
  min-height:48px;
  display:flex;
  align-items:center;
  justify-content:center;
  color:white;
  text-decoration:none;
  border:none;
  cursor:pointer;
  padding:12px 20px;
  border-radius:999px;
  font-size:1.05rem;
  font-weight:900;
  background:linear-gradient(180deg,rgba(255,255,255,.18),rgba(255,255,255,.07));
  box-shadow:0 10px 24px rgba(0,0,0,.25);
}

.hud{
  display:grid;
  grid-template-columns:repeat(3,1fr);
  gap:14px;
  padding:16px 22px 0;
}

.hud-card{
  padding:14px;
  border-radius:18px;
  background:linear-gradient(180deg,rgba(255,255,255,.12),rgba(255,255,255,.05));
  border:1px solid rgba(255,255,255,.1);
  box-shadow:0 12px 28px rgba(0,0,0,.22);
}

.hud-label{
  opacity:.72;
  margin-bottom:6px;
  font-size:.85rem;
  letter-spacing:.08em;
  text-transform:uppercase;
}

.hud-value{
  font-size:1.18rem;
  font-weight:900;
}

.game-area{
  flex:1;
  display:grid;
  grid-template-columns:minmax(320px,1fr) 310px;
  gap:24px;
  padding:24px 24px 100px;
  align-items:start;
}

.board-panel{
  display:flex;
  justify-content:center;
  align-items:flex-start;
}

.backgammon-board{
  width:min(76vw,860px);
  aspect-ratio:1.7 / 1;
  position:relative;
  display:grid;
  grid-template-columns:repeat(13,1fr);
  grid-template-rows:1fr 1fr;
  gap:0;
  padding:18px;
  border-radius:28px;
  background:
    radial-gradient(circle at 50% 0%,rgba(255,255,255,.18),transparent 34%),
    linear-gradient(135deg,#9b5a2c,#5a2e16 55%,#251007);
  border:1px solid rgba(255,255,255,.2);
  box-shadow:
    0 30px 80px rgba(0,0,0,.58),
    inset 0 0 0 12px rgba(48,22,8,.6),
    inset 0 0 45px rgba(255,255,255,.12);
  overflow:hidden;
}

.board-half{
  display:grid;
  grid-template-columns:repeat(6,1fr);
  gap:0;
  position:absolute;
  width:calc(50% - 34px);
  height:calc(100% - 36px);
  top:18px;
}

.board-half.left{
  left:18px;
}

.board-half.right{
  right:18px;
}

.bar{
  position:absolute;
  top:18px;
  bottom:18px;
  left:50%;
  width:42px;
  transform:translateX(-50%);
  border-radius:18px;
  background:
    linear-gradient(180deg,rgba(255,255,255,.18),rgba(0,0,0,.3)),
    linear-gradient(90deg,#2b1207,#6c3518,#2b1207);
  box-shadow:
    inset 0 0 18px rgba(0,0,0,.42),
    0 0 18px rgba(0,0,0,.25);
  z-index:5;
}

.point{
  position:relative;
  display:flex;
  align-items:center;
  justify-content:flex-start;
  overflow:visible;
  cursor:pointer;
}

.point.top{
  flex-direction:column;
}

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

.triangle{
  position:absolute;
  left:8%;
  right:8%;
  height:88%;
  clip-path:polygon(50% 100%,0 0,100% 0);
  opacity:.92;
  filter:drop-shadow(0 4px 8px rgba(0,0,0,.35));
}

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

.point:nth-child(odd) .triangle{
  background:linear-gradient(180deg,#f4cf8d,#be7036);
}

.point:nth-child(even) .triangle{
  background:linear-gradient(180deg,#402016,#170a05);
}

.point.highlight{
  background:rgba(255,225,120,.16);
  box-shadow:inset 0 0 0 3px rgba(255,225,120,.65);
}

.checker{
  width:min(62%,36px);
  aspect-ratio:1;
  border-radius:50%;
  margin:2px 0;
  z-index:3;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:.7rem;
  font-weight:900;
  box-shadow:
    inset 0 5px 8px rgba(255,255,255,.18),
    inset 0 -7px 12px rgba(0,0,0,.35),
    0 6px 11px rgba(0,0,0,.38);
}

.checker.player{
  background:radial-gradient(circle at 35% 22%,#6d7480,#11151c 60%,#020203);
  border:1px solid rgba(255,255,255,.42);
}

.checker.ai{
  background:radial-gradient(circle at 35% 22%,#fff,#ded7c7 58%,#968770);
  border:1px solid rgba(0,0,0,.35);
  color:#17100a;
}

.side-panel{
  display:flex;
  flex-direction:column;
  gap:16px;
  position:sticky;
  top:106px;
}

.action-btn{
  border:none;
  border-radius:20px;
  padding:17px;
  cursor:pointer;
  font-size:1.05rem;
  font-weight:900;
  color:#170d04;
  background:linear-gradient(180deg,#ffe28f,#ffb92f);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.55),
    0 14px 28px rgba(0,0,0,.28);
}

.action-btn.secondary{
  background:linear-gradient(180deg,rgba(255,255,255,.2),rgba(255,255,255,.08));
  color:white;
}

.action-btn:disabled{
  opacity:.45;
  cursor:not-allowed;
}

.status-box,
.legend{
  padding:17px;
  border-radius:20px;
  background:linear-gradient(180deg,rgba(255,255,255,.12),rgba(255,255,255,.045));
  border:1px solid rgba(255,255,255,.1);
  line-height:1.55;
  font-weight:800;
  box-shadow:0 12px 28px rgba(0,0,0,.22);
}

.legend{
  display:flex;
  flex-direction:column;
  gap:12px;
}

.mini-checker{
  width:18px;
  height:18px;
  display:inline-block;
  border-radius:50%;
  margin-right:8px;
  vertical-align:-3px;
}

.mini-checker.player{
  background:#090b10;
  border:1px solid rgba(255,255,255,.6);
}

.mini-checker.ai{
  background:#f4ead6;
  border:1px solid rgba(0,0,0,.35);
}

.instructions-overlay{
  position:fixed;
  inset:0;
  background:rgba(0,0,0,.78);
  display:flex;
  align-items:center;
  justify-content:center;
  padding:18px;
  z-index:999;
}

.hidden{
  display:none;
}

.instructions-modal{
  width:min(94vw,780px);
  max-height:86vh;
  overflow:auto;
  border-radius:28px;
  background:
    radial-gradient(circle at top,rgba(164,97,42,.28),transparent 40%),
    #160d06;
  border:1px solid rgba(255,255,255,.12);
  padding:28px;
  position:relative;
  box-shadow:0 30px 90px rgba(0,0,0,.6);
}

.instructions-modal h2{
  margin-bottom:20px;
}

.instructions-content{
  display:flex;
  flex-direction:column;
  gap:18px;
  line-height:1.7;
}

.instructions-content ul{
  padding-left:24px;
}

.close-btn{
  position:absolute;
  top:18px;
  right:18px;
  width:42px;
  height:42px;
  border:none;
  border-radius:50%;
  font-weight:900;
  cursor:pointer;
}

@media (max-width:1000px){
  .game-area{
    grid-template-columns:1fr;
  }

  .side-panel{
    position:relative;
    top:auto;
  }

  .backgammon-board{
    width:min(94vw,860px);
  }
}

@media (max-width:680px){
  .top-bar{
    flex-direction:column;
    align-items:flex-start;
  }

  .top-left{
    width:100%;
    gap:16px;
  }

  .title-wrap h1{
    font-size:1.55rem;
  }

  .top-actions,
  .top-btn{
    width:100%;
  }

  .hud{
    grid-template-columns:1fr;
    padding:14px 14px 0;
  }

  .game-area{
    padding:14px 14px 90px;
  }

  .backgammon-board{
    width:94vw;
    border-radius:20px;
    padding:12px;
  }

  .board-half{
    top:12px;
    height:calc(100% - 24px);
  }

  .board-half.left{
    left:12px;
  }

  .board-half.right{
    right:12px;
  }

  .bar{
    top:12px;
    bottom:12px;
    width:28px;
  }

  .checker{
    width:min(68%,24px);
    font-size:.55rem;
    margin:1px 0;
  }
}
