:root{
  --bg1:#0b1220;
  --bg2:#090a16;
  --card: rgba(255,255,255,.06);
  --stroke: rgba(255,255,255,.12);
  --text: rgba(255,255,255,.92);
  --muted: rgba(255,255,255,.65);
  --shadow: 0 18px 55px rgba(0,0,0,.55);
  --shadow2: 0 12px 30px rgba(0,0,0,.40);
  --r: 22px;
  --r2: 18px;

  --neonA:#00e5ff; /* player */
  --neonC:#ff4fd8; /* ai */
  --neonB:#8a5cff;
  --good:#20f7b8;
  --warn:#ffb13b;
  --bad:#ff4f6d;
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  font-family:Inter, system-ui, -apple-system, Segoe UI, Arial, sans-serif;
  color:var(--text);
  background:
    radial-gradient(1200px 600px at 15% 5%, rgba(0,229,255,.15), transparent 60%),
    radial-gradient(900px 500px at 85% 10%, rgba(255,79,216,.14), transparent 60%),
    radial-gradient(900px 650px at 55% 100%, rgba(138,92,255,.14), transparent 60%),
    linear-gradient(160deg, var(--bg1), var(--bg2));
  overflow-x:hidden;
}

.bg-blobs .blob{
  position:fixed;
  width:520px; height:520px;
  filter: blur(55px);
  opacity:.38;
  border-radius:50%;
  z-index:0;
  animation: floaty 11s ease-in-out infinite;
}
.bg-blobs .b1{left:-150px; top:-130px; background: rgba(0,229,255,.55)}
.bg-blobs .b2{right:-190px; top:-120px; background: rgba(255,79,216,.50); animation-delay:-3s}
.bg-blobs .b3{left:40%; bottom:-260px; background: rgba(138,92,255,.55); animation-delay:-6s}

@keyframes floaty{
  0%,100%{transform:translate3d(0,0,0) scale(1)}
  50%{transform:translate3d(0,18px,0) scale(1.05)}
}

.wrap{
  position:relative;
  z-index:1;
  max-width:1100px;
  margin:0 auto;
  padding:26px 18px 46px;
}

.topbar{
  display:flex;
  gap:14px;
  align-items:center;
  justify-content:space-between;
  padding:16px 16px;
  border:1px solid var(--stroke);
  background:linear-gradient(180deg, rgba(255,255,255,.07), rgba(255,255,255,.04));
  border-radius:var(--r);
  box-shadow: var(--shadow2);
  backdrop-filter: blur(10px);
}

.back{
  color:var(--text);
  text-decoration:none;
  display:flex;
  gap:10px;
  align-items:center;
  padding:10px 12px;
  border-radius:14px;
  border:1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.04);
  transition:.2s;
  white-space:nowrap;
}
.back:hover{transform:translateY(-1px); border-color:rgba(0,229,255,.28)}
.back-ic{font-weight:800; opacity:.9}

.brand{display:flex; gap:12px; align-items:center; min-width:0}
.badge{
  width:42px; height:42px;
  display:grid; place-items:center;
  border-radius:14px;
  background: radial-gradient(circle at 20% 20%, rgba(0,229,255,.55), rgba(138,92,255,.22));
  border:1px solid rgba(255,255,255,.14);
  box-shadow: 0 10px 24px rgba(0,229,255,.12);
  font-weight:900;
}
.brand-text{min-width:0}
.title{
  font-size:18px;
  font-weight:800;
  letter-spacing:-.3px;
  line-height:1.05;
}
.neon{
  background: linear-gradient(90deg, var(--neonA), var(--neonC), var(--neonB));
  -webkit-background-clip:text;
  background-clip:text;
  color:transparent;
}
.vs{
  font-size:12px;
  padding:4px 9px;
  border-radius:999px;
  border:1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.05);
  margin-left:8px;
  opacity:.9;
}
.sub{
  margin-top:4px;
  font-size:12.5px;
  color:var(--muted);
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
  max-width:560px;
}

.top-actions{display:flex; gap:10px; align-items:center; white-space:nowrap}
.btn{
  border:0;
  cursor:pointer;
  color: #08111f;
  font-weight:900;
  padding:10px 14px;
  border-radius:14px;
  background: linear-gradient(90deg, var(--neonA), var(--neonC));
  box-shadow: 0 12px 28px rgba(0,229,255,.14);
  transition:.18s;
}
.btn:hover{transform: translateY(-1px); filter:brightness(1.05)}
.btn:active{transform: translateY(0px); filter:brightness(.98)}
.btn.ghost{
  color:var(--text);
  border:1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.05);
  box-shadow:none;
}
.btn[disabled]{opacity:.45; cursor:not-allowed; transform:none !important}
.btn.mini{padding:8px 10px; border-radius:12px; font-size:12.5px}

.panel{
  margin-top:16px;
  border-radius: var(--r);
  border:1px solid var(--stroke);
  background: linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.03));
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  padding:18px;
}

.stats{
  display:grid;
  grid-template-columns: 1fr 1fr 1.15fr;
  gap:12px;
  align-items:stretch;
}

.stat{
  padding:14px 14px;
  border-radius:18px;
  background: rgba(255,255,255,.05);
  border:1px solid rgba(255,255,255,.10);
}
.stat-top{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
}
.stat-label{font-size:12px; color:var(--muted); font-weight:800}
.stat-row{
  display:flex; gap:14px; flex-wrap:wrap;
  margin-top:10px;
}
.mini{font-size:12.5px; color:rgba(255,255,255,.78)}
.mini b{color:var(--text)}
.mini.big{font-size:13.5px; font-weight:900}

.chip{
  display:inline-flex;
  align-items:center;
  gap:10px;
  padding:7px 10px;
  border-radius:999px;
  border:1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.05);
  font-weight:900;
  font-size:12px;
}

.dot{
  width:10px; height:10px;
  border-radius:50%;
  box-shadow: 0 0 18px rgba(0,229,255,.55);
}
.dot-p{background: var(--neonA); box-shadow:0 0 18px rgba(0,229,255,.55)}
.dot-a{background: var(--neonC); box-shadow:0 0 18px rgba(255,79,216,.55)}

.settings .hint{
  margin-top:10px;
  font-size:12.5px;
  color:rgba(255,255,255,.70);
  line-height:1.5;
}
.turn{
  margin-top:12px;
  display:flex; align-items:center; gap:10px;
  padding:10px 12px;
  border-radius:14px;
  border:1px solid rgba(255,255,255,.12);
  background: rgba(0,0,0,.18);
  font-weight:900;
}
.pulse{
  width:10px; height:10px; border-radius:50%;
  background: var(--good);
  box-shadow: 0 0 14px rgba(32,247,184,.55);
  animation: pulse 1.1s ease-in-out infinite;
}
@keyframes pulse{
  0%,100%{transform:scale(1); opacity:1}
  50%{transform:scale(1.35); opacity:.55}
}

.seg{
  margin-top:10px;
  display:flex;
  border-radius:16px;
  border:1px solid rgba(255,255,255,.12);
  background: rgba(0,0,0,.16);
  overflow:hidden;
}
.seg-btn{
  flex:1;
  padding:10px 12px;
  cursor:pointer;
  border:0;
  color:rgba(255,255,255,.82);
  background:transparent;
  font-weight:900;
}
.seg-btn.active{
  color:#08111f;
  background: linear-gradient(90deg, var(--neonA), var(--neonC));
}

.board-wrap{
  margin-top:14px;
  border-radius: var(--r);
  border:1px solid rgba(255,255,255,.10);
  background: rgba(0,0,0,.18);
  padding:16px;
}

.board-head{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:12px;
  margin-bottom:12px;
}

.muted{color:var(--muted); font-size:12.5px}

.board{
  width: min(560px, 100%);
  aspect-ratio: 1/1;
  margin: 0 auto;
  border-radius: 22px;
  padding: 12px;
  background:
    radial-gradient(circle at 20% 20%, rgba(0,229,255,.10), transparent 35%),
    radial-gradient(circle at 80% 30%, rgba(255,79,216,.10), transparent 35%),
    rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.12);
  display:grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
  position: relative;
}

.cell{
  border-radius: 18px;
  background: rgba(255,255,255,.06);
  border:1px solid rgba(255,255,255,.09);
  display:grid;
  place-items:center;
  cursor:pointer;
  position:relative;
  overflow:hidden;
  transition: .12s;
}
.cell:hover{transform: translateY(-1px); border-color: rgba(255,255,255,.16)}
.cell.locked{cursor:not-allowed; opacity:.95}
.cell.empty{opacity:1}

.stone{
  width: 62%;
  height: 62%;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.14);
  box-shadow: 0 12px 24px rgba(0,0,0,.35);
  transform: translateZ(0);
}
.stone.p{
  background:
    radial-gradient(circle at 25% 25%, rgba(255,255,255,.25), transparent 50%),
    radial-gradient(circle at 60% 70%, rgba(0,229,255,.35), transparent 55%),
    rgba(0,229,255,.16);
  box-shadow: 0 0 18px rgba(0,229,255,.35), 0 12px 24px rgba(0,0,0,.35);
}
.stone.a{
  background:
    radial-gradient(circle at 25% 25%, rgba(255,255,255,.25), transparent 50%),
    radial-gradient(circle at 60% 70%, rgba(255,79,216,.35), transparent 55%),
    rgba(255,79,216,.16);
  box-shadow: 0 0 18px rgba(255,79,216,.35), 0 12px 24px rgba(0,0,0,.35);
}

/* Territory fill */
.terr{
  position:absolute;
  inset:0;
  border-radius:18px;
  opacity:.9;
}
.terr.p{
  background: radial-gradient(circle at 35% 25%, rgba(0,229,255,.16), transparent 60%),
              rgba(0,229,255,.06);
  border: 1px solid rgba(0,229,255,.20);
  box-shadow: 0 0 18px rgba(0,229,255,.12);
}
.terr.a{
  background: radial-gradient(circle at 35% 25%, rgba(255,79,216,.16), transparent 60%),
              rgba(255,79,216,.06);
  border: 1px solid rgba(255,79,216,.20);
  box-shadow: 0 0 18px rgba(255,79,216,.12);
}

.bottom-actions{
  margin-top:14px;
  display:flex;
  justify-content:space-between;
  gap:10px;
  flex-wrap:wrap;
}

/* Modals */
.modal{
  position:fixed; inset:0;
  display:none;
  align-items:center;
  justify-content:center;
  background: rgba(0,0,0,.55);
  z-index:50;
  padding: 16px;
}
.modal.show{display:flex}
.modal-card{
  width:min(560px, 100%);
  border-radius: 22px;
  border:1px solid rgba(255,255,255,.14);
  background: linear-gradient(180deg, rgba(255,255,255,.08), rgba(255,255,255,.04));
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  overflow:hidden;
}
.modal-card.glow{
  border-color: rgba(0,229,255,.22);
  box-shadow: 0 18px 55px rgba(0,229,255,.12), var(--shadow);
}
.modal-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding: 14px 16px;
  border-bottom:1px solid rgba(255,255,255,.12);
}
.modal-head h3{margin:0; font-size:16px; font-weight:900}
.x{
  border:1px solid rgba(255,255,255,.16);
  background: rgba(255,255,255,.06);
  color: var(--text);
  border-radius: 12px;
  width:38px; height:38px;
  cursor:pointer;
}
.modal-body{padding: 14px 16px 16px}
.modal-actions{display:flex; gap:10px; justify-content:flex-end; margin-top:14px; flex-wrap:wrap}
.how{margin:0; padding-left:18px; color:rgba(255,255,255,.85)}
.how li{margin:8px 0}

@media (max-width: 980px){
  .topbar{flex-wrap:wrap; justify-content:center}
  .sub{max-width: 92vw}
  .top-actions{width:100%; justify-content:center}
  .stats{grid-template-columns: 1fr; }
}
