/* The playable board in algorithmic-improvements-chess.html.
   Board and piece styles come from chess_deps/chess_deps.css (chessground). */

.chessapp {
  font-size: 0.95rem;
  position: relative;
}

.banner {
  display: none;
  padding: 0.6em 0.9em;
  margin-bottom: 0.8em;
  border-radius: 4px;
  background: #fdf3d8;
  border: 1px solid #e3cf95;
}
.flash {
  display: none;
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  padding: 0.6em 1.1em;
  border-radius: 4px;
  background: #e8f1fb;
  border: 1px solid #a9c7e8;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}

/* ---- persistent header: engine load, and the queue ---- */

.joinrow {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.6em;
  padding: 0.7em 1em;
  background: #faf9f6;
  border: 1px solid #ddd8cf;
  border-radius: 4px;
  margin-top: 1.4em;
}
.enginestatus { font-size: 0.9em; color: #666; margin: 0.3em 0; }
#yourstatus { font-size: 0.85rem; color: #666; }
.queuestrip {
  display: flex;
  gap: 0.5em;
  overflow-x: auto;
  margin-left: auto;
  list-style: none;
  padding: 0;
  max-width: 100%;
  flex: 1 1 auto;
}
.queuestrip li {
  font-family: monospace;
  font-size: 0.82rem;
  color: #666;
  background: #efece5;
  padding: 0.15em 0.5em;
  border-radius: 10px;
  white-space: nowrap;
}
.queuestrip li.you { background: #2c6e49; color: #fff; font-weight: 700; }

.viewbar {
  display: flex;
  align-items: center;
  gap: 0.8em;
  margin-bottom: 0.8em;
}

button {
  font: inherit;
  padding: 0.4em 0.9em;
  cursor: pointer;
  border: 1px solid #c9c2b6;
  border-radius: 4px;
  background: #fff;
}
#join { background: #2c6e49; border-color: #2c6e49; color: #fff; font-weight: 600; }
#evaltoggle { font-size: 0.85rem; color: #555; }

/* ---- the grid of every game ---- */

/* Six games at a time: 3x2 when there is room, 2x3 when there is not. */
.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.1em;
}
@media (max-width: 780px) {
  .grid { grid-template-columns: repeat(2, 1fr); }
}
.grid .miniboard { width: 100%; aspect-ratio: 1 / 1; height: auto; }
.grid .empty { grid-column: 1 / -1; padding: 3em 1em; color: #999; font-style: italic; text-align: center; }

.mini { cursor: pointer; }
.mini:hover .miniboard { outline: 2px solid #999; }
.mini.mine .miniboard { outline: 2px solid #2c6e49; }
.mini.done { opacity: 0.55; }
.minilabel, .minifoot {
  font-family: monospace;
  font-size: 0.75rem;
  color: #666;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.minifoot { color: #999; }

/* ---- one game, close up ---- */

.playarea { display: flex; gap: 1.4em; align-items: flex-start; }
.boardcol { flex: 0 0 auto; }
.boardrow { display: flex; gap: 0.5em; position: relative; }

#mainboard.cg-wrap { width: 480px; height: 480px; }

.seat {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  width: 480px;
  margin-left: 22px;
  padding: 0.25em 0;
}
.seatid { display: flex; align-items: baseline; gap: 0.6em; }
.seatname { font-weight: 600; }
.seatnote { font-size: 0.78rem; color: #6a3d9a; font-family: monospace; }
.seatname.engine { color: #6a3d9a; }
.clock {
  font-variant-numeric: tabular-nums;
  font-family: monospace;
  font-size: 1.1rem;
  padding: 0.05em 0.45em;
  border-radius: 3px;
  background: #eee;
}
.clock.running { background: #d8ecd8; }
.clock.urgent { background: #f6d4d4; }
.clock.engineclock { background: #ece2f6; font-size: 0.9rem; }

.evalbar {
  position: relative;
  width: 28px;
  height: 480px;
  background: #4a4a4a;
  border-radius: 2px;
  overflow: hidden;
  flex: 0 0 auto;
}
#evalfill {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 50%;
  background: #f0f0f0;
  transition: height 0.35s ease;
}
.evalbar.flipped #evalfill { bottom: auto; top: 0; }
#evalnum {
  position: absolute;
  bottom: 2px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 0.58rem;
  font-family: monospace;
  color: #333;
  line-height: 1.4;
}

.promotion {
  display: none;
  position: absolute;
  inset: 0;
  left: 22px;
  background: rgba(255,255,255,0.88);
  align-items: center;
  justify-content: center;
  gap: 0.6em;
  z-index: 5;
}
.promo { width: 3em; height: 3em; font-size: 1.3rem; }

.side { flex: 1 1 auto; min-width: 240px; }
.side button { margin: 0.5em 0.4em 0 0; }
#gamestatus {
  display: none;
  padding: 0.5em 0.8em;
  background: #f4f2ee;
  border-left: 3px solid #6a3d9a;
  font-weight: 600;
  margin-bottom: 0.6em;
}
.movelist {
  display: grid;
  grid-template-columns: 2.4em 1fr 1fr;
  gap: 0.1em 0.4em;
  height: 240px;
  overflow-y: auto;
  font-family: monospace;
  font-size: 0.9rem;
  padding: 0.4em 0.6em;
  border: 1px solid #ddd8cf;
  border-radius: 4px;
  align-content: start;
}
.movelist .num { color: #999; }

#finished { display: none; margin-bottom: 1.2em; padding: 0.9em 1em; background: #f4f2ee; border: 1px solid #ddd8cf; border-radius: 4px; }
#resulttext { font-weight: 600; margin-bottom: 0.5em; }
#permalink { font: inherit; font-size: 0.8rem; width: 24em; max-width: 60%; padding: 0.35em; }

.stripwrap { margin-top: 1.6em; }
.striphead {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #888;
  margin-bottom: 0.5em;
}
.strip { display: flex; gap: 0.8em; overflow-x: auto; padding-bottom: 0.6em; }
.strip .mini { flex: 0 0 auto; width: 120px; }
.strip .miniboard { width: 120px; height: 120px; }
.strip .empty { color: #aaa; font-style: italic; font-size: 0.85rem; }

@media (max-width: 900px) {
  .grid { grid-template-columns: repeat(2, 1fr); }
  .playarea { flex-direction: column; }
  #mainboard.cg-wrap, .seat { width: min(480px, 88vw); }
  #mainboard.cg-wrap { height: min(480px, 88vw); }
  .evalbar { height: min(480px, 88vw); }
  .queuestrip { max-width: 100%; margin-left: 0; }
}

/* ---- "are you still playing?" ---- */
.awaypopup {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.35);
  z-index: 1000;
}
.awaybox {
  max-width: 26em;
  margin: 1em;
  padding: 1.2em 1.4em;
  background: #fff;
  border-radius: 6px;
  box-shadow: 0 6px 30px rgba(0, 0, 0, 0.25);
  text-align: center;
}
.awaybox p { margin: 0 0 1em; }
.awaybox button {
  font: inherit;
  padding: 0.5em 1.2em;
  background: #2c6e49;
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

/* LaTeX booktabs-style tables: heavy top/bottom rules, light midrule, no verticals. */
table.booktabs {
  border-collapse: collapse;
  margin: 1.2em auto;
  border-top: 2px solid #000;
  border-bottom: 2px solid #000;
}
table.booktabs th,
table.booktabs td {
  border: none;
  padding: 0.25em 0.8em;
  text-align: left;
  vertical-align: top;
}
table.booktabs thead th {
  font-weight: normal;
  border-bottom: 1px solid #000;
  padding-top: 0.4em;
}
table.booktabs tbody tr:first-child td { padding-top: 0.4em; }
table.booktabs tbody tr:last-child td { padding-bottom: 0.4em; }
table.booktabs td:first-child,
table.booktabs th:first-child {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* The Pentium Pro's monitor: its 80x25 VGA text screen, scaled so 80 columns fill the width. */
.vgawrap { margin-top: 1.2em; container-type: inline-size; }
.vgawrap.stale .vga { opacity: 0.45; }
.vgacap { font-size: 0.8rem; color: #777; margin-bottom: 0.3em; }
.vga {
  margin: 0;
  padding: 0.8em 1em;
  background: #000;
  color: #aaa;
  border-radius: 6px;
  font-family: "Menlo", "DejaVu Sans Mono", "Consolas", monospace;
  font-size: 11px;
  font-size: 1.95cqw;       /* 80 columns of 0.6em ~ the box's width */
  line-height: 1.2;
  white-space: pre;
  overflow-x: auto;
  transition: opacity 0.3s;
}
.vgarow { height: 1.2em; }   /* one block per row, so coloured rows meet with no seams */
.vga span { display: inline-block; height: 100%; vertical-align: top; }
