:root{
  --bg:#0f172a;
  --panel:#111c33;
  --card:#0b1224;
  --text:#e5e7eb;
  --muted:#94a3b8;

  --lightSquare:#cbd5e1;
  --darkSquare:#334155;

  --redPiece:#ef4444;
  --blackPiece:#111827;
  --pieceRing: rgba(255,255,255,.12);

  --select:#60a5fa;
  --move:#22c55e;
  --capture:#f59e0b;
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Noto Sans Hebrew", sans-serif;
  background: radial-gradient(1200px 800px at 30% 10%, #1f2a44, var(--bg));
  color:var(--text);
}

.topbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding:14px 16px;
  border-bottom:1px solid rgba(255,255,255,.08);
  position:sticky;
  top:0;
  backdrop-filter: blur(10px);
  background: rgba(15,23,42,.75);
  z-index:10;
}

.brand{display:flex; flex-direction:column; gap:2px}
.logo{font-weight:800; letter-spacing:.5px; font-size:18px}
.subtitle{color:var(--muted); font-size:13px}

.controls{display:flex; gap:8px; flex-wrap:wrap; justify-content:flex-end}
.btn{
  border:1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.08);
  color:var(--text);
  padding:10px 12px;
  border-radius:12px;
  cursor:pointer;
  font-weight:700;
}
.btn:disabled{opacity:.5; cursor:not-allowed}
.btn.secondary{background: rgba(96,165,250,.14)}
.btn.tertiary{background: rgba(34,197,94,.14)}

.layout{
  display:grid;
  grid-template-columns: 1fr 340px;
  gap:16px;
  padding:16px;
  max-width: 1200px;
  margin: 0 auto;
}

.panel{
  background: rgba(17,28,51,.72);
  border:1px solid rgba(255,255,255,.08);
  border-radius:18px;
  padding:14px;
  box-shadow: 0 20px 80px rgba(0,0,0,.35);
}

.statusRow{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:10px;
  flex-wrap:wrap;
}

.turn, .score{font-weight:800}
#turnLabel.red{color: var(--redPiece)}
#turnLabel.black{color: #d1d5db}

.hint{
  margin-top:10px;
  color:var(--muted);
  font-size:13px;
}

.boardWrap{
  margin-top:14px;
  display:flex;
  justify-content:center;
}

.board{
  width:min(92vw, 640px);
  aspect-ratio: 1 / 1;
  display:grid;
  grid-template-columns: repeat(8, 1fr);
  border-radius:18px;
  overflow:hidden;
  border:1px solid rgba(255,255,255,.10);
  touch-action: manipulation;
}

.square{
  position:relative;
  display:flex;
  align-items:center;
  justify-content:center;
  user-select:none;
  -webkit-tap-highlight-color: transparent;
}

.square.light{background: var(--lightSquare)}
.square.dark{background: var(--darkSquare)}

.piece{
  width:72%;
  height:72%;
  border-radius:999px;
  display:flex;
  align-items:center;
  justify-content:center;
  box-shadow: 0 10px 25px rgba(0,0,0,.35);
  border: 2px solid var(--pieceRing);
  transform: translateZ(0);
}

.piece.red{background: radial-gradient(circle at 30% 30%, #ff9a9a, var(--redPiece))}
.piece.black{background: radial-gradient(circle at 30% 30%, #6b7280, var(--blackPiece))}

.piece.king::after{
  content:"♛";
  font-size: clamp(16px, 3.2vw, 26px);
  color: rgba(255,255,255,.92);
  text-shadow: 0 3px 12px rgba(0,0,0,.45);
}

.square.selectable::after{
  content:"";
  position:absolute;
  inset: 10%;
  border-radius:14px;
  border: 2px solid rgba(96,165,250,.55);
  pointer-events:none;
}

.square.selected::after{
  content:"";
  position:absolute;
  inset: 8%;
  border-radius:14px;
  border: 3px solid rgba(96,165,250,.95);
  pointer-events:none;
}

.square.target::after{
  content:"";
  position:absolute;
  inset: 10%;
  border-radius:14px;
  border: 2px solid rgba(96,165,250,.75);
  pointer-events:none;
}
.square.target.move::after{border-color: rgba(34,197,94,.95)}
.square.target.capture::after{border-color: rgba(245,158,11,.98)}

.mobileTips{
  margin-top:12px;
  font-size:12px;
  color: var(--muted);
}

.side{display:flex; flex-direction:column; gap:14px}
.card{
  background: rgba(11,18,36,.78);
  border:1px solid rgba(255,255,255,.08);
  border-radius:18px;
  padding:14px;
}
.card h2{margin:0 0 10px 0; font-size:16px}
.card ul{margin:0; padding:0 18px 0 0; color: var(--text)}
.card li{margin:8px 0; color:#dbe2ee}
.note{margin-top:10px; color:var(--muted); font-size:13px}

.footer{
  padding:18px 16px;
  text-align:center;
  color:rgba(255,255,255,.45);
  font-size:12px;
}

@media (max-width: 980px){
  .layout{grid-template-columns: 1fr;}
}
