/* Fly Chess: only what is particular to this page. Shared layout, type and
   colour live in /css/lab.css.

   The board is a grid with BOTH axes pinned to 8 equal tracks inside a 1:1
   box. Setting only the columns leaves the rows to size themselves from the
   piece glyph, which is what made the squares rectangles. Everything inside a
   square is sized in `cqi` (percent of the board's own width) so the pieces
   and coordinates scale with the board rather than the viewport. */

:root {
  --sq-light: #eee6d4;
  --sq-dark: #b08d62;           /* walnut, to sit with the site's bronze */
  --sq-mark: #e2c46a;           /* selection / last move */
  --hint: rgba(32, 43, 51, .2);
}

/* ---- layout ---- */
.game { display: grid; grid-template-columns: minmax(320px, 1.05fr) minmax(0, 1fr); gap: 22px; align-items: start; }
@media (max-width: 980px) { .game { grid-template-columns: 1fr; } }
.game-side { display: grid; gap: 18px; min-width: 0; }
.twocol { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 20px; align-items: start; }
.boardpanel { padding: 16px; }

/* ---- board ---- */
.boardwrap { position: relative; }
#board {
  display: grid; grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(8, 1fr);
  aspect-ratio: 1 / 1; width: min(100%, 76vh); max-width: 100%; margin-inline: auto;
  container-type: inline-size; overflow: hidden; user-select: none; touch-action: manipulation;
  outline: 1px solid var(--ink); outline-offset: 4px; border-radius: 1px;
}
.sq { position: relative; display: grid; place-items: center; cursor: pointer; min-width: 0; }
.sq.l { background: var(--sq-light); }
.sq.d { background: var(--sq-dark); }
.sq .p, #promo button { font-family: "Segoe UI Symbol", "Apple Symbols", "Noto Sans Symbols 2", "DejaVu Sans", serif; font-variant-emoji: text; }
.sq .p { font-size: 9.4cqi; line-height: 1; position: relative; z-index: 3; will-change: transform;
  -webkit-text-stroke: .055em rgba(0, 0, 0, .55); paint-order: stroke fill; }
.sq.w .p { color: #fbfaf6; text-shadow: 0 .03em .04em rgba(0, 0, 0, .3); }
.sq.b .p { color: #2a2826; -webkit-text-stroke: .045em #111; }
.sq.mark::before { content: ""; position: absolute; inset: 0; background: var(--sq-mark); opacity: .55; z-index: 1; }
.sq.chk::after { content: ""; position: absolute; inset: 0; z-index: 1;
  background: radial-gradient(circle, rgba(204, 90, 66, .95) 10%, rgba(204, 90, 66, .45) 40%, rgba(204, 90, 66, 0) 72%); }
.sq .dot { position: absolute; width: 28%; height: 28%; border-radius: 50%; background: var(--hint); z-index: 2; pointer-events: none; }
.sq.cap .dot { width: 100%; height: 100%; background: none; border: .9cqi solid var(--hint); }
.sq .co { position: absolute; font: 600 2.5cqi/1 var(--f-mono); z-index: 2; pointer-events: none; }
.sq .co.f { right: 5%; bottom: 3%; }
.sq .co.r { left: 5%; top: 3%; }
.sq.l .co { color: var(--sq-dark); }
.sq.d .co { color: var(--sq-light); }
.sq .p.moving { z-index: 6; }

#status { margin: 16px 0 12px; font-family: var(--f-display); font-size: 19px; color: var(--ink); min-height: 28px; }
#status b { color: var(--bronze); font-weight: 500; }
.lab .btn.subtle { color: var(--muted); }
.lab .btn.btn-sm { padding: 5px 10px; font-size: 12px; }
.lab .btn.live { border-color: var(--sig-in); box-shadow: inset 0 -2px 0 var(--sig-in); }

/* ---- promotion ---- */
#promo { position: absolute; inset: 0; display: none; align-items: center; justify-content: center;
  background: rgba(246, 244, 239, .82); z-index: 8; }
#promo.on { display: flex; }
#promo .opts { display: flex; gap: 8px; background: var(--sheet); border: 1px solid var(--ink); padding: 10px 12px; }
#promo button { font-size: 30px; line-height: 1; padding: 8px 12px; min-width: 56px; background: var(--paper);
  border: 1px solid var(--rule-2); border-radius: 3px; cursor: pointer; }
#promo button:hover { border-color: var(--bronze); }
#promo .lbl { color: var(--muted); font-size: 10.5px; text-align: center; margin-top: 8px; letter-spacing: .13em; text-transform: uppercase; }

/* ---- game score ---- */
#pgnbox { display: none; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--rule); }
#pgnbox.on { display: block; }
#pgn { width: 100%; min-height: 96px; font: 12px/1.55 var(--f-mono); resize: vertical; background: var(--paper); }

/* ---- the brain ---- */
.brainplate { position: relative; }
#brain { width: 100%; display: block; }
.viewbtns { position: absolute; top: 8px; right: 8px; display: flex; border: 1px solid var(--plate-rule);
  border-radius: 3px; overflow: hidden; background: var(--plate); }
.viewbtns button { font: 10.5px var(--f-mono); letter-spacing: .04em; padding: 5px 9px; border: 0;
  background: none; color: var(--plate-dim); cursor: pointer; }
.viewbtns button + button { border-left: 1px solid var(--plate-rule); }
.viewbtns button.on { background: var(--plate-2); color: var(--plate-ink); }
.viewbtns button:focus-visible { outline: 2px solid var(--bronze); outline-offset: -2px; }
@media (max-width: 560px) {
  .viewbtns { position: static; margin: 0 8px 8px; justify-content: center; }
  .viewbtns button { flex: 1; }
}
.mbonwrap { padding: 6px 8px; }
#mbon { width: 100%; height: 74px; display: block; }

/* ---- candidate moves ---- */
#cands { max-height: 210px; overflow: auto; font-size: 13px; font-variant-numeric: tabular-nums; }
#cands div { display: flex; justify-content: space-between; padding: 4px 8px; border-bottom: 1px dotted var(--rule); font-family: var(--f-mono); font-size: 12.5px; }
#cands div.best { background: var(--bronze-wash); color: var(--bronze-deep); font-weight: 600; }
#cands .mv { font-family: var(--f-mono); }
#cands .lab-note { border: 0; font-family: var(--f-body); }

/* ---- rating ---- */
.elo { display: flex; align-items: baseline; gap: 12px; margin-bottom: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--rule); }
.elo b { font: 400 46px/1 var(--f-display); color: var(--ink); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.elo span { color: var(--muted); font-size: 13px; }
.chartwrap { position: relative; }
#eloChart { width: 100%; height: 190px; display: block; }
.tip { position: absolute; pointer-events: none; background: var(--ink); color: var(--paper); border-radius: 2px;
  padding: 5px 8px; font: 11px var(--f-mono); transform: translate(-50%, -125%); white-space: nowrap; opacity: 0;
  transition: opacity .12s; z-index: 4; }
.tip.on { opacity: 1; }
.tip b { color: #f0d9b5; }
.trainrow { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.pill { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font: 12px var(--f-mono); }
.pill i { width: 7px; height: 7px; border-radius: 50%; background: var(--sig-in); display: inline-block; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: .35; } 50% { opacity: 1; } }

/* ---- leaderboard ---- */
#lb table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
#lb th { text-align: left; font-size: 10.5px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  color: var(--muted); padding: 0 0 8px; border-bottom: 1px solid var(--ink); }
#lb td { padding: 8px 0; border-bottom: 1px solid var(--rule); }
#lb th.n, #lb td.n { text-align: right; font-family: var(--f-mono); width: 3em; }
#lb tr.me td { color: var(--bronze-deep); font-weight: 700; }
#lb .rank { color: var(--muted); width: 2em; font-family: var(--f-mono); font-size: 12px; }
#lb .who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 1px; width: 99%; }
#lb .empty { color: var(--muted); font-size: 14px; }
.signin { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.signin .who { color: var(--ink); font-weight: 700; font-size: 14px; }

/* ---- the dopamine flood after a win ---- */
#flood { position: fixed; inset: 0; pointer-events: none; opacity: 0; z-index: 50;
  background: radial-gradient(circle at 50% 45%, rgba(201, 162, 39, .42), rgba(201, 162, 39, 0) 62%); }
#flood.go { animation: fl 2.4s ease-out; }
@keyframes fl { 0% { opacity: 0; } 12% { opacity: 1; } 100% { opacity: 0; } }
#floodtxt { position: fixed; inset: 0; display: none; align-items: center; justify-content: center; z-index: 51;
  pointer-events: none; font: italic 400 64px var(--f-display); color: var(--bronze-deep); letter-spacing: -.02em; }
#floodtxt.go { display: flex; animation: ft 2.4s ease-out; }
@keyframes ft { 0% { opacity: 0; transform: scale(.94); } 15% { opacity: 1; transform: scale(1); } 75% { opacity: 1; } 100% { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  #flood.go, #floodtxt.go { animation-duration: .01ms; }
  .sq .p { transition: none !important; }
  .pill i { animation: none; opacity: .8; }
}
