:root{
  --bg:#0b1020;
  --text:#e9eefc;
  --muted:#a8b3d6;

  --panel: rgba(255,255,255,.06);
  --border: rgba(255,255,255,.12);

  --light:#e7d6b0;
  --dark:#5a3f20;
  --dark2:#51381c;

  --hint:#2dd4bf;
  --capture:#ff3d71;
  --select:#fbbf24;
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial;
  background: radial-gradient(1200px 700px at 20% 10%, #1a2560 0%, var(--bg) 60%);
  color:var(--text);
}

.app{max-width:1100px; margin:0 auto; padding:22px}

.topbar{display:flex; align-items:center; justify-content:space-between; gap:16px; margin-bottom:18px}

.topbarLeft{min-width: 260px;}

.topbarCenter{
  flex: 1;
  display:flex;
  align-items:center;
  justify-content:center;
  padding: 0 10px;
}

.brand{
  font-family: ui-rounded, "Segoe Print", "Segoe Script", "Bradley Hand", "Comic Sans MS", ui-sans-serif;
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 0.8px;
  background: linear-gradient(90deg, rgba(255, 209, 102, 0.95), rgba(124, 92, 255, 0.95));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 10px 26px rgba(0,0,0,0.35);
}

h1{margin:0; font-size:22px; letter-spacing:.2px}
.status{margin-top:6px; color:var(--muted); font-size:14px; min-height:18px}

.actions{display:flex; gap:10px}
.btn{
  appearance:none;
  border:1px solid rgba(255,255,255,.14);
  background: linear-gradient(180deg, rgba(124,92,255,.18), rgba(124,92,255,.06));
  color:var(--text);
  padding:10px 12px;
  border-radius:10px;
  cursor:pointer;
  font-weight:700;
}
.btn:disabled{opacity:.5; cursor:not-allowed}

.main{display:grid; grid-template-columns: 1fr 320px; gap:18px; align-items:start}

.boardPanel{
  background: linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.03));
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 16px;
  padding: 16px;
}

.board{
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  aspect-ratio: 1 / 1;
  display:grid;
  grid-template-columns: repeat(8, 1fr);
  border-radius: 14px;
  overflow:hidden;
  border:1px solid rgba(0,0,0,.55);
  box-shadow: 0 18px 55px rgba(0,0,0,.35);
  position:relative;
}

 .boardWrap{
   width: 100%;
   max-width: 720px;
   margin: 0 auto;
 }

 .coordsRow{
   display:grid;
   grid-template-columns: repeat(8, 1fr);
   gap: 0;
   padding-left: 18px;
   padding-right: 0;
   margin-bottom: 8px;
 }

 .coordsRowBottom{
   margin-top: 8px;
   margin-bottom: 0;
 }

 .coordsMid{
   display:grid;
   grid-template-columns: 18px 1fr;
   align-items: stretch;
   gap: 0;
 }

 .coordsCol{
   display:grid;
   grid-template-rows: repeat(8, 1fr);
   padding-top: 0;
   padding-bottom: 0;
 }

 .coordCell{
   color: rgba(255,255,255,.70);
   font-size: 12px;
   font-weight: 900;
   line-height: 1;
   display:flex;
   align-items:center;
   justify-content:center;
   user-select:none;
 }

.cell{
  position:relative;
  display:flex;
  align-items:center;
  justify-content:center;
  user-select:none;
}
.cell.light{background: linear-gradient(180deg, var(--light), #dcc99f)}
.cell.dark{background: linear-gradient(180deg, var(--dark), var(--dark2))}

.cell.selected{outline: 3px solid rgba(251,191,36,.9); outline-offset: -3px;}

.hintDot{
  position:absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(45,212,191,.85);
  box-shadow: 0 0 0 4px rgba(45,212,191,.22);
}

.hintCapture{
  position:absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(255,61,113,.85);
  box-shadow: 0 0 0 4px rgba(255,61,113,.22);
}

.piece{
  width: 82%;
  height: 82%;
  border-radius: 14px;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size: 42px;
  line-height: 1;
  filter: drop-shadow(0 10px 16px rgba(0,0,0,.35));
  touch-action:none;
}

.piece.white{color:#f8fafc}
.piece.black{color:#0b1020}

.piece.draggingPiece{
  position: fixed;
  z-index: 9999;
  pointer-events:none;
}

body.dragging{user-select:none; cursor:grabbing}

.boardOverlay{
  position:absolute;
  inset:0;
  display:flex;
  align-items:center;
  justify-content:center;
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(2px);
}

.boardOverlayCard{
  width: min(520px, calc(100% - 28px));
  background: linear-gradient(180deg, rgba(255,255,255,.10), rgba(255,255,255,.06));
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 16px;
  padding: 16px 14px;
  text-align:center;
}

.boardOverlayTitle{font-size:18px; font-weight:900; margin:0}
.boardOverlaySubtitle{margin-top:10px; color: rgba(255,255,255,.82); font-weight:800}

.legend{display:flex; gap:12px; justify-content:center; margin-top:12px; flex-wrap:wrap}
.legendRow{display:flex; align-items:center; gap:8px; color:var(--muted); font-size:13px}
.swatch{width:14px; height:14px; border-radius:4px; display:inline-block; border:1px solid rgba(0,0,0,.25)}
.swatch.hint{background:rgba(45,212,191,.85)}
.swatch.capture{background:rgba(255,61,113,.85)}

.side{display:flex; flex-direction:column; gap:14px}
.card{
  background: linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.03));
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 16px;
  padding: 14px 14px;
}
.card h2{margin:0 0 10px 0; font-size:16px}
.rules p{margin:8px 0; color:var(--muted); font-size:13px; line-height:1.35}
.info{color:var(--muted); font-size:13px; line-height:1.45; min-height:60px}

.aiRow{
  display:grid;
  grid-template-columns:56px 1fr;
  gap:12px;
  align-items:start;
}

.aiAvatar{
  width:56px;
  height:56px;
  border-radius:999px;
  background:
    radial-gradient(circle at 35% 35%, rgba(255,255,255,0.50), transparent 45%),
    radial-gradient(circle at 50% 70%, rgba(0,0,0,0.18), transparent 55%),
    linear-gradient(180deg, #ffd2a6, #f1b98d);
  position:relative;
  box-shadow: inset 0 3px 10px rgba(255,255,255,0.14), inset 0 -10px 16px rgba(0,0,0,0.22), 0 14px 22px rgba(0,0,0,0.30);
}

.aiAvatar::before{
  content:"";
  position:absolute;
  inset:-2px -2px 18px -2px;
  border-radius:999px;
  background:
    radial-gradient(circle at 50% 15%, rgba(255,255,255,0.10), transparent 60%),
    linear-gradient(180deg, #2a2a2a, #101010);
  clip-path: ellipse(65% 55% at 50% 25%);
  opacity:0.95;
}

.aiAvatar::after{
  content:"";
  position:absolute;
  inset:0;
  border-radius:999px;
  background:
    radial-gradient(circle at 38% 52%, rgba(0,0,0,0.85) 0 2.6px, transparent 3px),
    radial-gradient(circle at 62% 52%, rgba(0,0,0,0.85) 0 2.6px, transparent 3px),
    radial-gradient(circle at 36% 50%, rgba(255,255,255,0.65) 0 1.1px, transparent 1.3px),
    radial-gradient(circle at 60% 50%, rgba(255,255,255,0.65) 0 1.1px, transparent 1.3px),
    radial-gradient(ellipse at 50% 72%, rgba(0,0,0,0.60) 0 6px, transparent 6.6px),
    radial-gradient(ellipse at 50% 69%, rgba(255,255,255,0.18) 0 8px, transparent 8.6px);
  opacity:0.85;
}

.aiDialog{
  margin-top:8px;
  padding:10px 12px;
  border:1px solid rgba(255,255,255,.14);
  border-radius:12px;
  background: linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.03));
  color:var(--muted);
  font-size:14px;
  font-weight:800;
  line-height:1.35;
  min-height:44px;
}
.footer{margin-top:14px; color:rgba(255,255,255,.55); font-size:12px}

.promotion{
  position:fixed;
  inset:0;
  display:flex;
  align-items:center;
  justify-content:center;
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(2px);
}

.promotionCard{
  width: min(520px, calc(100% - 28px));
  background: linear-gradient(180deg, rgba(255,255,255,.10), rgba(255,255,255,.06));
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 16px;
  padding: 16px 14px;
  text-align:center;
}

.promotionTitle{font-size:18px; font-weight:900}
.promotionSubtitle{margin-top:8px; color:rgba(255,255,255,.82); font-weight:800}
.promotionRow{margin-top:12px; display:flex; gap:10px; justify-content:center; flex-wrap:wrap}
.promoBtn{
  appearance:none;
  border:1px solid rgba(255,255,255,.18);
  background: rgba(255,255,255,.06);
  color:var(--text);
  padding:10px 12px;
  border-radius:10px;
  cursor:pointer;
  font-weight:800;
}
.promoBtn:hover{border-color: rgba(45,212,191,.55)}

@media (max-width: 980px){
  .main{grid-template-columns: 1fr;}
  .board{max-width: 680px}
  .piece{font-size: 40px}
  .topbarCenter{display:none}
}
