:root {
  /* title row (32) + controls row (44) */
  --topbar-h: 76px;
  /* game controls */
  --bottombar-h: 44px;
  /* how tall the move drawer is when open */
  --drawer-h: 20vh;
  /* updated by JS when drawer opens */
  --canvas-bottom: var(--bottombar-h);

  /* App surfaces */
  --app-bg: #222;
  --bar-bg: #2a2a2a;
  --drawer-bg: #262626;

  /* Text */
  --text: #d0d0d0;
  --text-muted: #9a9a9a;

  /* Board */
  --board-light: #e0e0e0;
  --board-dark: #6a6a6a;

  /* Overlays */
  --ov-last-from: rgba(255, 215,   0, 0.26);
  --ov-last-to:   rgba(255, 235,  90, 0.38);
  --ov-selected:  rgba(255, 255,   0, 0.22);
  --ov-legal:     rgba(  0, 255,   0, 0.16);
  --ov-capture:   rgba(255,   0,   0, 0.18);
  --ov-check:     rgba(255,   0,   0, 0.22);

  /* Eval bar */
  --eval-track: rgba(255,255,255,0.04);
  --eval-white: rgba(255,255,255,0.70);
  --eval-black: rgba(0,0,0,0.70);

  /* Captured material */
  --captured-halo-white: rgba(255, 255, 255, 0.40);
  --captured-halo-black: rgba(185, 185, 185, 0.36);
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--app-bg);
  color: var(--text);
  overflow: hidden;
}

/* Prevent iOS long-press selection/callouts */
#topbar, #topbar *,
#bottombar, #bottombar *,
#drawer, #drawer * {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.hidden { display: none !important; }

/* TOP BAR */
#topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--topbar-h);
  background: var(--bar-bg);
  border-bottom: 1px solid #222;
  z-index: 30;
  display: flex;
  flex-direction: column;
}

#titleRow {
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#titleText {
  color: #fff;
  font: 18px ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  letter-spacing: 0.2px;
}

#controlsRow {
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 6px 10px;
}

button {
  height: 36px;
  padding: 0 10px;
  border: 0;
  border-radius: 8px;
  background: #333;
  color: #fff;
  font: 14px ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

button:active { transform: scale(0.98); }

/* BOTTOM BAR */
#bottombar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--bottombar-h);
  background: var(--bar-bg);
  border-top: 1px solid #222;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 10px;
}

#bottomPlay, #bottomReview {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

/* DRAWER */
#drawer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: var(--bottombar-h);
  height: var(--drawer-h);
  background: var(--drawer-bg);
  border-top: 1px solid #2a2a2a;
  z-index: 25;
  transform: translateY(100%);
  transition: transform 160ms ease-out;
  display: flex;
  flex-direction: column;
}

#drawer.drawer-open {
  transform: translateY(0%);
}

#movesTable {
  overflow: auto;
  -webkit-overflow-scrolling: touch; /* iOS momentum scrolling */

  padding: 4px 6px calc(24px + env(safe-area-inset-bottom)) 6px;
  box-sizing: border-box;

  flex: 1 1 auto;
}

#movesTable::after {
  content: "";
  display: block;
  height: 56px;
}

/* Move table row: 3 columns (num / white / black) */
.moveRow {
  display: grid;
  grid-template-columns: 42px 1fr 1fr; /* tighter move # */
  gap: 4px;
  padding: 3px 6px;                   /* tighter row height */
  border-bottom: 1px solid rgba(255,255,255,0.06);
  align-items: center;
}

.moveNum {
  color: #aaa;
  text-align: right;
  padding-right: 4px;
  font: 12px ui-monospace, Menlo, monospace;
}

.moveCell {
  color: #eee;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 7px;
  padding: 3px 6px;                   /* tighter cell */
  font: 12px ui-monospace, Menlo, monospace;
}

.moveCell.empty {
  background: transparent;
  border: 1px solid transparent;
  color: #666;
}

.moveCell.active {
  outline: 2px solid rgba(0,255,0,0.30);
}

/* CANVAS */
#board {
  position: fixed;
  left: 0;
  top: var(--topbar-h);
  width: 100vw;
  height: calc(100vh - var(--topbar-h) - var(--canvas-bottom));
  display: block;
}

#fatalError {
  position: fixed;
  left: 8px;
  right: 8px;
  top: 8px;
  max-height: 45vh;
  padding: 10px;
  overflow: auto;
  background: rgba(0,0,0,0.92);
  color: #ffdddd;
  border: 1px solid #553;
  border-radius: 10px;
  font: 12px ui-monospace, Menlo, monospace;
  white-space: pre-wrap;
  z-index: 9999;
}

