:root {
  --bg: #0f1216;
  --panel: #171b21;
  --panel-2: #1e242c;
  --line: #2a323c;
  --text: #e8edf2;
  --muted: #9aa7b4;
  --accent: #4f9dff;
  --sel: #f7d36a;
  --check: #e74c3c;
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  background: radial-gradient(1200px 600px at 50% -10%, #1b2230, var(--bg));
  color: var(--text);
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(15, 18, 22, 0.6);
  backdrop-filter: blur(8px);
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand .logo { font-size: 30px; line-height: 1; }
.brand h1 {
  margin: 0;
  font-size: 26px;
  letter-spacing: 3px;
  font-weight: 800;
  background: linear-gradient(90deg, #fff, var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.brand .tag {
  font-size: 12px;
  color: var(--muted);
  border: 1px solid var(--line);
  padding: 2px 8px;
  border-radius: 20px;
}

.controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button {
  background: transparent; color: var(--muted); border: 0;
  padding: 8px 14px; cursor: pointer; font-size: 14px;
}
.seg button.active { background: var(--accent); color: #06101f; font-weight: 700; }

.ctl {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--muted);
}
.ctl select {
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 7px 9px; font-size: 13px; cursor: pointer;
}

.btn {
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--line); padding: 8px 14px;
  border-radius: 10px; cursor: pointer; font-size: 14px; transition: 0.15s;
}
.btn:hover { border-color: var(--accent); }
.btn.ghost { background: transparent; }

.layout {
  display: grid;
  grid-template-columns: minmax(340px, 1fr) 280px;
  gap: 24px;
  padding: 24px;
  max-width: 1180px;
  margin: 0 auto;
}

.board-wrap { display: flex; flex-direction: column; align-items: stretch; gap: 12px; }

.status {
  text-align: center; padding: 10px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; font-weight: 600;
}
.status.check { color: var(--check); border-color: var(--check); }

.board-row { display: flex; gap: 12px; align-items: stretch; }

/* Evaluation bar */
.evalbar {
  width: 18px; flex: 0 0 18px;
  border-radius: 9px; overflow: hidden;
  background: #20262e; border: 1px solid var(--line);
  position: relative;
}
.eval-fill {
  position: absolute; left: 0; right: 0; bottom: 0;
  height: 50%;
  background: linear-gradient(180deg, #f4f6fb, #cfd6e0);
  transition: height 0.4s ease;
}

/* 3D scene */
.scene {
  flex: 1;
  aspect-ratio: 1 / 1;
  width: 100%;
  max-width: 620px;
  border-radius: 12px;
  overflow: hidden;
  background:
    radial-gradient(120% 90% at 50% 0%, #243043, #11151b 75%);
  border: 1px solid var(--line);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
  touch-action: none;
}
.scene canvas { display: block; width: 100%; height: 100%; }

/* Material / captured + eval number */
.material {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 14px;
  min-height: 40px;
}
.mat { display: flex; align-items: center; gap: 8px; font-size: 22px; }
.mat.right { justify-content: flex-end; }
.mat .who { font-size: 11px; color: var(--muted); letter-spacing: 1px; text-transform: uppercase; }
.mat .cap b { font-size: 13px; color: var(--accent); vertical-align: middle; }
.evalnum {
  font-variant-numeric: tabular-nums; font-weight: 800;
  font-size: 15px; color: var(--text);
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 8px; padding: 4px 10px; min-width: 54px; text-align: center;
}

.sidebar {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px;
  display: flex; flex-direction: column;
}
.sidebar h2 { margin: 0 0 10px; font-size: 16px; color: var(--muted); letter-spacing: 1px; }
.moves {
  margin: 0; padding-left: 28px; overflow-y: auto;
  flex: 1; max-height: 460px; font-variant-numeric: tabular-nums;
}
.moves li { padding: 3px 0; border-bottom: 1px dashed var(--line); }
.moves li span { display: inline-block; min-width: 70px; }
.hintbar { font-size: 11px; color: var(--muted); text-align: center; margin: 12px 0 0; }
.credits { margin-top: 10px; font-size: 12px; color: var(--muted); text-align: center; }

/* Modals */
.modal {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex; align-items: center; justify-content: center; z-index: 50;
}
.modal.hidden { display: none; }
.modal-card {
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 24px; text-align: center; min-width: 260px;
}
.modal-card h3 { margin: 0 0 8px; font-size: 22px; }
.promo-choices { display: flex; gap: 10px; margin-top: 12px; justify-content: center; }
.promo-choices button {
  font-size: 40px; background: #ebecd0; border: 1px solid var(--line);
  border-radius: 10px; width: 64px; height: 64px; cursor: pointer;
}
.promo-choices button:hover { background: var(--sel); }

@media (max-width: 920px) {
  .layout { grid-template-columns: 1fr; }
  .moves { max-height: 180px; }
  .scene { max-width: none; }
}
