* { box-sizing: border-box; }
:root {
  color-scheme: dark;
  --text: #f0efe4;
  --muted: #b1b7c0;
  --line: #444951;
  --accent: #bac9df;
  --sans: "Inter", "Segoe UI", sans-serif;
  --serif: "Baskervville", Georgia, serif;
}
html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: #1c1f23;
  color: var(--text);
  font: 16px/1.45 var(--sans);
}
button, input { font: inherit; }
button {
  cursor: pointer;
  color: inherit;
  border: 0;
  background: transparent;
}
button:disabled { opacity: .4; cursor: default; }
button:focus-visible, summary:focus-visible, label:has(input:focus-visible) {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
[hidden] { display: none !important; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
i[data-icon] {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
}
i[data-icon] svg { display: block; width: 100%; height: 100%; }

.game, .viewport { position: fixed; inset: 0; }
.game {
  isolation: isolate;
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
}
.viewport {
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  outline: none;
  cursor: grab;
  background: radial-gradient(ellipse at 49% 44%, #1f2a3d, #141b28 47%, #090c12 91%);
}
.viewport.over-square { cursor: pointer; }
.viewport.dragging { cursor: grabbing; }
.viewport canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }

.match-hud, .menu-toggle {
  position: absolute;
  top: max(18px, env(safe-area-inset-top));
}
.match-hud {
  left: max(23px, env(safe-area-inset-left));
  padding-top: 3px;
  display: flex;
  align-items: baseline;
  gap: 10px;
  pointer-events: none;
  text-shadow: 0 1px 5px #111419;
}
.match-hud h1 {
  margin: 0;
  font: 500 clamp(17px, 1.3vw, 23px)/1.25 var(--sans);
  letter-spacing: -.035em;
}
.turn-token {
  width: 11px;
  height: 11px;
  border: 1px solid #e2dcc3;
  border-radius: 50%;
  background: #eee3c9;
}
.turn-token.black { background: #414b59; border-color: #a6aeba; }
.hud-details {
  display: flex;
  gap: 13px;
  align-items: center;
  margin-top: 3px;
  color: #b6bdc6;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
/* Above the board: White's blocks, the turn, Black's blocks; the side to move is underlined. */
.scoreboard {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
}
.match-game .scoreboard { left: calc((100% - var(--rail)) / 2); }
.score-bar { display: grid; grid-template-columns: 1fr auto 1fr; background: #11151bd9; border: 1px solid #ffffff1c; border-radius: 6px; }
.score-side { position: relative; display: flex; align-items: center; gap: 9px; min-width: 132px; padding: 9px 15px; }
.score-side.white { justify-content: flex-end; }
.score-side.on::after { content: ""; position: absolute; left: 12px; right: 12px; bottom: -1px; height: 3px; border-radius: 2px; background: #eee3c9; }
.score-side.black.on::after { background: #a6aeba; }
.score-side .turn-token { flex: 0 0 auto; }
.score-side.on .turn-token { box-shadow: 0 0 0 3px #ffffff26; }
.score-cubes { display: flex; align-items: center; gap: 3px; }
.score-count { display: none; font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.score-side.endless .score-count { display: inline; }
.score-turn { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-width: 64px; padding: 5px 15px 6px; border-inline: 1px solid #ffffff17; }
.score-turn b { font-size: 26px; font-weight: 600; line-height: 1; font-variant-numeric: tabular-nums; }
.score-track { display: flex; align-items: center; gap: 3px; height: 15px; }
.score-track i { width: 4px; height: 7px; border-radius: 1px; background: #3a4048; }
.score-track i.past { background: #7d8794; }
.score-track i.now { height: 12px; background: var(--text); box-shadow: 0 0 6px #f0efe466; }
.scoreboard .cube { display: block; width: 18px; height: 19px; overflow: visible; }
.score-track .cube { width: 14px; height: 15px; margin-left: 3px; }
.scoreboard .cube.ghost { color: #6b737e; }
.scoreboard .cube.empty { color: #4d525a; }
.scoreboard .cube.due { color: #86d0c6; animation: block-due 1.3s ease-in-out infinite; }
.scoreboard .cube.fresh { animation: block-arrives 1.8s ease-out both; }
@keyframes block-due {
  0%, 100% { transform: scale(1); filter: drop-shadow(0 0 0 #86d0c600); }
  50% { transform: scale(1.16); filter: drop-shadow(0 0 6px #86d0c6ee); }
}
@keyframes block-arrives {
  0% { transform: translateY(-22px); opacity: 0; filter: drop-shadow(0 0 10px #86d0c6); }
  40% { transform: none; opacity: 1; filter: drop-shadow(0 0 10px #86d0c6); }
  100% { filter: drop-shadow(0 0 0 #86d0c600); }
}
@media (prefers-reduced-motion: reduce) {
  .scoreboard .cube.due, .scoreboard .cube.fresh { animation: none; }
  .scoreboard .cube.due { filter: drop-shadow(0 0 5px #86d0c6cc); }
}
#check-tag { padding: 1px 9px; border-radius: 3px; background: #11151bd9; color: #f4bd94; font-size: 13px; }
/* Online clocks at the outer ends of the bar: the side to move lights up, under ten seconds turns red. */
.score-clock { min-width: 62px; padding: 3px 8px; border-radius: 3px; background: #ffffff0d; color: #c3c9d1; font-size: 19px; font-weight: 600; line-height: 1.2; text-align: center; font-variant-numeric: tabular-nums; }
.score-clock.active { background: #ebe6d4; color: #15181c; }
.score-clock.low { color: #ff9a8c; }
.score-clock.active.low { background: #c0473b; color: #fff; }
.menu-toggle {
  right: max(18px, env(safe-area-inset-right));
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  color: #d8dde5;
  border-radius: 3px;
  touch-action: manipulation;
}
.menu-toggle:hover, .icon-button:hover { background: #b9cae316; }
.menu-toggle i { width: 23px; height: 23px; }
.notice {
  position: absolute;
  left: 50%;
  bottom: max(19px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  pointer-events: none;
  color: #dae1ea;
  font-size: 14px;
  text-align: center;
  text-shadow: 0 1px 4px #101317;
}
dialog {
  width: min(460px, calc(100vw - 32px));
  max-height: calc(100dvh - 40px);
  overflow: auto;
  overscroll-behavior: contain;
  padding: 0;
  border: 1px solid #59606b;
  border-radius: 3px;
  background: #202328;
  color: var(--text);
  box-shadow: 0 18px 80px #06080a80;
  scrollbar-width: thin;
  scrollbar-color: #515b69 #202328;
}
dialog::backdrop { background: #0b0d1099; }
#menu-dialog { width: min(610px, calc(100vw - 24px)); }
#menu-dialog:has(#device-open:not([hidden])) { width: min(710px, calc(100vw - 24px)); }
#studies-dialog { width: min(640px, calc(100vw - 24px)); }
/* The caption runs under the title and the switches, so a narrow dialog never squeezes it. */
#menu-dialog .dialog-head { display: grid; grid-template-columns: 1fr auto; gap: 0 14px; }
#menu-dialog .dialog-head > div:first-child { display: contents; }
#menu-dialog h2 { grid-area: 1 / 1; }
#menu-dialog .menu-switches { grid-area: 1 / 2; }
#menu-dialog .match-caption { grid-area: 2 / 1 / auto / -1; }
.dialog-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  padding: 20px 20px 14px;
  border-bottom: 1px solid var(--line);
}
.dialog-head h2 { margin: 0; font: 400 30px/1.1 var(--serif); letter-spacing: -.045em; }
.match-caption { margin: 7px 0 0; color: var(--muted); font-size: 13px; }
.icon-button, .board-tools button {
  display: grid;
  place-items: center;
  padding: 0;
  width: 36px;
  height: 36px;
  color: var(--muted);
  border-radius: 3px;
}
.icon-button[aria-pressed=true], .board-tools button:is([aria-pressed=true], [aria-expanded=true]) { background: #333b46; color: #d9e3f1; }
/* The menu: sound, zen and fullscreen in its title bar, then the places to go. */
.menu-switches { display: flex; gap: 2px; margin: -4px -8px 0 auto; }
.menu-list { display: flex; gap: 8px; padding: 16px 20px 18px; }
.menu-list button {
  flex: 1 1 0;
  min-width: 0;
  white-space: nowrap;
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 16px 4px 13px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: #262a31;
  font-size: 14.5px;
}
.menu-list button i { width: 24px; height: 24px; color: #c3cfdf; }
.menu-list button:hover:enabled { background: #2f343b; border-color: #5d6674; }
/* Board tools in the corner of the board: the look of the pieces, then the camera. */
.board-tools {
  position: absolute;
  left: max(14px, env(safe-area-inset-left));
  bottom: calc(var(--under, 0px) + max(16px, env(safe-area-inset-bottom)));
  display: grid;
  gap: 2px;
  padding: 4px;
  border: 1px solid #3a4250;
  border-radius: 4px;
  background: #141a24cc;
}
.board-tools button { width: 32px; height: 32px; touch-action: manipulation; }
.board-tools button:hover:enabled { background: #b9cae316; }
.board-tools i { width: 16px; height: 16px; }
.camera-tools { display: grid; gap: 2px; padding-top: 4px; border-top: 1px solid #3a4250; }
.match-game.zen .board-tools { display: none; }
.dialog-body { padding: 18px 20px; }
.dialog-foot {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  border-top: 1px solid var(--line);
  padding: 12px 20px;
}
.primary-button, .button { min-height: 37px; padding: 6px 14px; font-size: 14px; }
.primary-button { background: var(--accent); color: #21262c; font-weight: 600; }
.primary-button:hover { background: #ccd9eb; }
.button:hover { background: #313740; }
.intro, .reserves { margin: 0 0 14px; }
.rule-row { display: flex; align-items: flex-start; gap: 11px; margin: 16px 0; }
.rule-symbol { color: var(--accent); padding-top: 2px; }
.rule-row h3 { font: 600 16px/1.3 var(--sans); margin: 0 0 4px; }
.rule-row p, details p { color: var(--muted); font-size: 15px; line-height: 1.5; margin: 0; }
details { border-top: 1px solid var(--line); padding: 11px 0 0; }
summary { cursor: pointer; }
details p { margin-top: 9px; }
fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }
legend { font-weight: 600; margin-bottom: 7px; padding: 0; }
.opponent-options { display: flex; gap: 6px; }
.opponent-options label { flex: 1; }
.opponent-options input, .position-option input { position: absolute; opacity: 0; }
.opponent-options span, .position-option {
  display: flex;
  align-items: center;
  gap: 9px;
  border: 1px solid var(--line);
  padding: 8px 10px;
  font-size: 14px;
  cursor: pointer;
}
.opponent-options input:checked + span, .position-option:has(input:checked) { background: #2f3641; border-color: #7b8a9e; }
.level-options span { justify-content: center; padding-inline: 4px; }
.level-control-host { display: block; }
.level-control {
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.02);
}
.level-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.level-head strong { font-size: 14px; font-weight: 600; }
.level-rating {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  background: rgba(169, 193, 224, 0.12);
  border: 1px solid rgba(169, 193, 224, 0.25);
  padding: 1px 7px;
  border-radius: 2px;
  display: inline-block !important;
  cursor: default !important;
}
.level-slider {
  position: static !important;
  opacity: 1 !important;
  width: 100%;
  margin: 2px 0;
  accent-color: var(--accent);
  cursor: pointer;
}
.level-scale {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.level-scale span {
  display: inline !important;
  border: 0 !important;
  padding: 0 !important;
  font-size: 11px !important;
  cursor: default !important;
}
.level-desc {
  margin: 2px 0 0;
  font-size: 12.5px;
  line-height: 1.35;
  color: var(--muted);
}
#match-levels { margin: 14px 20px 3px; }
/* The five piece looks, pictured, open beside the board tools. */
#piece-style {
  position: absolute;
  left: calc(100% + 9px);
  top: -1px;
  width: min(352px, calc(100vw - 72px));
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  padding: 10px;
  border: 1px solid #59606b;
  border-radius: 3px;
  background: #202328;
  box-shadow: 0 12px 40px #06080a80;
}
#piece-style label { display: grid; gap: 4px; justify-items: center; color: var(--muted); font-size: 12px; cursor: pointer; }
#piece-style label:has(input:checked) { color: var(--text); }
#piece-style input { position: absolute; opacity: 0; }
#piece-style b { width: 100%; aspect-ratio: 3 / 2; border: 1px solid var(--line); border-radius: 3px; background: #1a1f28 center / cover; }
#piece-style input:checked + b { outline: 2px solid var(--accent); outline-offset: 1px; }
#piece-style input[value=ink] + b { background-image: url("thumbs/pieces-ink.webp"); }
#piece-style input[value=classic] + b { background-image: url("thumbs/pieces-classic.webp"); }
#piece-style input[value=marble] + b { background-image: url("thumbs/pieces-marble.webp"); }
#piece-style input[value=wood] + b { background-image: url("thumbs/pieces-wood.webp"); }
#piece-style input[value=metal] + b { background-image: url("thumbs/pieces-metal.webp"); }
#new-levels, .positions-set, .variants-set, #player-colors { margin-top: 17px; }
#position-options, #variant-options { display: grid; gap: 5px; }
.variant-option .check-mark {
  flex: 0 0 16px;
  height: 16px;
  margin-left: auto;
  border: 1px solid #7b8a9e;
  border-radius: 2px;
  display: grid;
  place-items: center;
  font-size: 12px;
  line-height: 1;
}
.variant-option:has(input:checked) .check-mark { background: var(--accent); color: #21252b; }
.variant-option:has(input:checked) .check-mark::after { content: "✓"; }
.variants-set:disabled .variant-option { opacity: .45; cursor: default; }
.position-option svg { flex: 0 0 31px; width: 31px; height: 31px; }
.position-option strong, .position-option small { display: block; }
.position-option small, .replace-note, .empty-record, .reserves { color: var(--muted); font-size: 14px; }
.replace-note { margin: 11px 0 0; }
.record-head, .record-row { display: grid; grid-template-columns: 36px 1fr 1fr; align-items: center; gap: 4px; }
.record-head { color: var(--muted); border-bottom: 1px solid var(--line); padding-bottom: 5px; font-size: 13px; }
#record { max-height: 50dvh; overflow-y: auto; }
.record-row { min-height: 30px; font-size: 15px; }
.move-num, .record-build { color: #a6b5ca; font-size: 12px; }
.record-build { margin-left: 5px; }
.promotion-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.promotion-choices button { padding: 9px; background: #2f3640; }
.promotion-choices b { font: 24px var(--serif); margin-right: 6px; }

@media (max-width: 520px) {
  .match-hud, .menu-toggle { top: max(10px, env(safe-area-inset-top)); }
  .match-hud { left: max(13px, env(safe-area-inset-left)); }
  .menu-toggle { right: max(8px, env(safe-area-inset-right)); }
  .hud-details { font-size: 12px; }
  .dialog-head, .dialog-body { padding-inline: 16px; }
}

a.button, a.primary-button { color: inherit; text-decoration: none; display: inline-flex; align-items: center; }
a.primary-button { color: #21262c; }
.menu-toggle > svg, .replay-transport svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.65;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.replay-transport {
  position: absolute;
  bottom: max(14px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 3px 7px;
  max-width: calc(100% - 24px);
  border: 1px solid #4f5661;
  border-radius: 4px;
  background: #202328f2;
}
.replay-transport button {
  display: grid;
  place-items: center;
  width: 35px;
  height: 35px;
  padding: 0;
  flex-shrink: 0;
  font-size: 13px;
}
.replay-transport button:hover:enabled { background: #333942; }
#watch-timeline { width: clamp(65px, 21vw, 260px); min-width: 30px; margin: 0 7px; accent-color: #a5b6cd; }
#watch-progress { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
#watch-speed { padding: 0 8px; width: auto; }
/* The analysis board's evaluation bar at the board's right edge. White's share fills from White's end. */
.eval {
  position: absolute;
  top: max(84px, calc(env(safe-area-inset-top) + 74px));
  bottom: 78px;
  right: max(18px, env(safe-area-inset-right));
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 6px;
  width: 46px;
}
.eval[hidden] { display: none; }
.eval-bar {
  position: relative;
  flex: 1 1 auto;
  width: 14px;
  max-height: min(62vh, 560px);
  overflow: hidden;
  border: 1px solid #4f5661;
  border-radius: 3px;
  background: #1a1d22;
  box-shadow: 0 2px 12px #0d0f1299;
}
.eval-bar::after { content: ""; position: absolute; left: 0; right: 0; top: 50%; border-top: 1px solid #b89d5a; opacity: .75; }
.eval-fill {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 50%;
  background: #ece3c6;
  transition: height .45s cubic-bezier(.3, .7, .3, 1);
}
.eval.flipped .eval-fill { top: 0; bottom: auto; }
.eval-score {
  min-width: 42px;
  padding: 2px 4px;
  border: 1px solid #ece3c6;
  border-radius: 3px;
  background: #ece3c6;
  color: #1d2228;
  font: 600 11.5px/1.3 var(--sans);
  font-variant-numeric: tabular-nums;
  text-align: center;
  white-space: nowrap;
}
.eval-score.black { border-color: #4f5661; background: #2b323d; color: #e8e1c8; }
.eval.pending .eval-score { opacity: .5; }
/* The bar floats over the board's right edge without shifting the camera. */
.match-game .eval { right: calc(var(--rail) + 14px); bottom: calc(var(--under) + 28px); }
@media (max-width: 520px) {
  .eval { width: 40px; }
  .eval-bar { width: 11px; }
  .eval-score { min-width: 36px; font-size: 10.5px; }
}
/* The engine's score and best line for the position on screen. */
.engine-line-head { margin: 0 0 5px; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.engine-line-head strong { margin-right: 4px; color: #dfe7f2; font-weight: 600; }
.engine-line-moves { display: flex; flex-wrap: wrap; gap: 2px 1px; margin-left: -5px; }
.line-move {
  padding: 2px 5px;
  border-radius: 3px;
  color: #d5deeb;
  font-size: 13px;
  line-height: 1.35;
  white-space: nowrap;
}
.line-move:hover { background: #2c4842; color: #c9f2eb; }
.line-number { margin-right: 3px; color: var(--muted); font-variant-numeric: tabular-nums; }
@media (max-width: 520px) {
  .engine-line-moves { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
}

.match-game { --rail: clamp(202px, 19vw, 264px); }
.match-game .viewport { right: var(--rail); bottom: var(--under); }
.match-game .menu-toggle { right: calc(var(--rail) + 12px); }
.match-game .notice { left: calc((100% - var(--rail)) / 2); bottom: calc(var(--under) + max(19px, env(safe-area-inset-bottom))); }
.match-panel {
  position: absolute;
  inset: 0 0 0 auto;
  width: var(--rail);
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: max(24px, env(safe-area-inset-top)) 16px max(12px, env(safe-area-inset-bottom));
  background: #202328;
  border-left: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}
.match-panel h2 { display: flex; align-items: center; gap: 6px; margin: 0 0 8px; font: 600 15px var(--sans); }
.match-panel h2 i, .mode-options i { width: 15px; height: 15px; }
.stock-row { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 7px; min-height: 25px; font-size: 13px; }
.stock-row + .stock-row { margin-top: 5px; }
.stock-row > span:first-child { min-width: 34px; }
.side-name small, .player-role { margin-left: 6px; color: var(--muted); font-size: 12px; }
.stock-row output { margin-left: auto; white-space: nowrap; color: var(--muted); }
.refill-note { color: var(--muted); font-size: 12px; }
.stock-row .material { flex: 1 0 100%; }
.stock-row .side-name { flex: 1 1 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Material imbalance, lichess style: captured pieces grouped by type, then the points lead. */
.material { display: flex; align-items: center; min-height: 19px; gap: 4px; overflow: hidden; white-space: nowrap; }
.mat-group { display: inline-flex; }
.material { min-height: 21px; }
.mat-group img { width: 21px; height: 21px; display: block; }
.mat-group img + img { margin-left: -11px; }
.mat-score { margin-left: 2px; color: #bdc8d8; font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.stock-pips { display: flex; flex-wrap: wrap; gap: 3px; }
.stock-pips i { width: 9px; height: 9px; border: 1px solid #a9b5c7; background: #e4dfc2; }
.black-pips i { background: #546070; border-color: #939ca9; }
.stock-pips .spent { background: transparent; border-color: #4d525a; }
.mode-options { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid #525a66; }
.mode-options button { display: flex; align-items: center; justify-content: center; gap: 5px; min-height: 34px; font-size: 14px; }
.mode-options button + button { border-left: 1px solid #525a66; }
.mode-options button[aria-pressed=true] { background: var(--accent); color: #21252b; }
.mode-options button:hover:enabled:not([aria-pressed=true]) { background: #313841; }
#placement-status { margin: 6px 0 0; font-size: 13px; line-height: 1.35; color: var(--muted); }
.rematch-box { display: grid; gap: 7px; margin-top: 10px; }
.rematch-sides { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid #525a66; }
.rematch-sides button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 32px;
  font-size: 13px;
}
.rematch-sides button + button { border-left: 1px solid #525a66; }
.rematch-sides button[aria-pressed=true] { background: #2f3641; color: var(--text); font-weight: 600; }
.rematch-sides button:hover:not([aria-pressed=true]) { background: #282e36; }
#rematch-btn { width: 100%; }
.rematch-box .button { justify-content: center; border: 1px solid var(--line); }
/* A finished game: Build and Move go, and what comes next takes their place. With nothing to offer, so does the section. */
.panel-phase.over > :is(.mode-options, #placement-status) { display: none; }
.panel-phase.over .rematch-box { margin-top: 0; }
.panel-phase.over:not(:has(> :not(.mode-options, #placement-status):not([hidden]))) { display: none; }
/* Playing on from the analysis board: the computer or a second player here, by the rules of the game on the board. */
.continuing :is(#llm-option, #online-option, #variant-set, #variant-note) { display: none; }
.game-actions { margin-top: 8px; }
.online-actions.game-actions button { flex: 0 1 auto; flex-direction: row; gap: 6px; padding: 5px 12px; font-size: 12px; }
#llm-warning, #replay-warning, #render-note { margin: 7px 0 0; color: #f2ce8a; font-size: 13px; line-height: 1.4; }
#llm-setup { color: var(--muted); overflow-wrap: anywhere; }
#llm-retry { margin-top: 6px; }
#llm-review { margin-top: 14px; }
#llm-conversation { overflow-wrap: anywhere; }
#llm-public-text { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 12em; overflow: auto; }
.panel-history { position: relative; flex: 1 1 0; min-height: 0; display: flex; flex-direction: column; padding-top: 14px; border-top: 1px solid var(--line); }
/* The move record opens from beside the Moves heading. */
#record-open { position: absolute; top: 6px; right: -6px; width: 32px; height: 32px; }
#record-open i { width: 16px; height: 16px; }

/* Online games: who is connected, what to answer, and the game's actions. */
.presence { display: inline-block; width: 7px; height: 7px; margin: 0 6px 1px 0; border: 1px solid #7d8590; border-radius: 50%; vertical-align: middle; }
.presence.on { background: #7cc46d; border-color: #7cc46d; }
.watchers { margin-left: auto; color: var(--muted); font-size: 12px; font-weight: 400; }
/* Connection quality, four bars like a phone's. */
.signal { display: inline-flex; align-items: flex-end; gap: 2px; height: 12px; margin-left: auto; }
.watchers:not([hidden]) + .signal { margin-left: 9px; }
.match-panel .signal i { width: 3px; height: 12px; border-radius: 1px; background: #474e58; }
.match-panel .signal i:nth-child(1) { height: 4px; }
.match-panel .signal i:nth-child(2) { height: 6px; }
.match-panel .signal i:nth-child(3) { height: 9px; }
.match-panel .signal i.on { background: #7cc46d; }
.qr { display: grid; place-items: center; margin-top: 16px; }
.qr:empty { display: none; }
.qr svg { width: 176px; height: 176px; border-radius: 3px; }
.record-foot { flex-wrap: wrap; }
.record-foot .button { border: 1px solid var(--line); }
.panel-online { display: grid; gap: 8px; }
.online-note { margin: 0; color: #d9dee6; font-size: 13px; line-height: 1.35; }
.online-ask, .online-after { display: flex; flex-wrap: wrap; gap: 6px; }
.online-ask > *, .online-after > * { flex: 1 1 auto; justify-content: center; min-height: 32px; padding: 4px 10px; border-radius: 3px; font-size: 13px; }
.online-ask .button, .online-after .button { border: 1px solid var(--line); }
.online-actions { display: flex; gap: 4px; }
.online-actions button { flex: 1 1 0; display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 0; padding: 5px 2px 4px; border: 1px solid var(--line); border-radius: 3px; color: #c7cdd6; font-size: 11px; }
.online-actions button:hover:enabled { background: #313841; }
.online-actions i { width: 16px; height: 16px; }
.online-actions .half { font-size: 15px; line-height: 16px; }
.online-actions button.confirm { background: #7a3329; border-color: #a7493c; color: #fff; }
.clock-set { margin-top: 17px; display: grid; gap: 8px; }
.clock-row { display: grid; grid-template-columns: 1fr auto; align-items: baseline; gap: 0 10px; font-size: 14px; }
.clock-row b { font-variant-numeric: tabular-nums; }
.clock-row input { grid-column: 1 / -1; width: 100%; margin: 3px 0 0; accent-color: var(--accent); }
.clock-off { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; }
.clock-off input { accent-color: var(--accent); }
.invite-text { margin: 0 0 10px; color: var(--muted); font-size: 14px; }
.invite-link { display: flex; gap: 6px; }
.invite-link input { flex: 1 1 auto; min-width: 0; padding: 6px 9px; border: 1px solid var(--line); background: #15181c; color: var(--text); font-size: 14px; }

/* Zen mode: the board and the bar only. An offer or request to answer floats over the bottom of the board. */
.match-game.zen { --rail: 0px !important; --dock: 0px !important; --under: 0px !important; }
.match-game.zen .review { display: none !important; }
.match-game.zen .match-panel {
  inset: auto 0 max(18px, env(safe-area-inset-bottom));
  width: auto;
  height: auto;
  display: flex;
  flex-direction: row;
  justify-content: center;
  padding: 0;
  border: 0;
  background: none;
  pointer-events: none;
}
.match-game.zen .match-panel > :not(.panel-online),
.match-game.zen .panel-online > :not(.online-note, .online-ask) { display: none !important; }
.match-game.zen .panel-online { width: min(340px, calc(100% - 32px)); padding: 10px 12px; border: 1px solid var(--line); border-radius: 4px; background: #202328f2; pointer-events: auto; }
.match-game.zen .panel-online:not(:has(> #online-ask:not([hidden]))) { display: none !important; }

/* Tutorial: the lesson replaces the move list, and the rail widens for its text. */
.match-game.tutoring { --rail: clamp(290px, 25vw, 380px); }
.match-game.tutoring .panel-history, .match-game.tutoring #watch-transport { display: none; }
/* Puzzles keep the move list and history controls under a compact puzzle panel. */
.match-game.tutoring.puzzling .tutorial { flex: 0 0 auto; }
.match-game.tutoring.studying .tutorial { flex: 0 1 auto; max-height: 64%; }
.match-game.tutoring.puzzling .panel-history { display: flex; }
.match-game.tutoring.puzzling #watch-transport { display: grid; }
/* Studies picker dialog: chapter groups with exercise checkmarks and free-study tags. */
.studies-body { display: grid; gap: 20px; }
.study-chapter-head { margin-bottom: 10px; }
.study-chapter-head h3 { margin: 0 0 2px; font: 600 15px/1.3 var(--sans); color: var(--text); }
.study-chapter-head p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.4; }
.study-items { display: grid; gap: 6px; }
.study-card {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  align-items: start;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: #262a31;
  text-align: left;
}
.study-card:hover { background: #2f343b; border-color: #5d6674; }
.study-card.current { background: #2f3641; border-color: var(--accent); }
.study-badge {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  margin-top: 1px;
  border: 1px solid #515a68;
  border-radius: 50%;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}
.study-badge.done { border-color: #4f8a7d; background: #2c4842; color: #c9f2eb; }
.study-badge.study { border-radius: 3px; border-color: #4d6280; background: #2a3850; color: #d4e0f0; }
.study-card-copy strong { display: block; font-size: 14.5px; font-weight: 600; color: var(--text); }
.study-card-copy small { display: block; margin-top: 2px; color: var(--muted); font-size: 13px; line-height: 1.35; }
.study-meta {
  align-self: center;
  padding: 2px 7px;
  border: 1px solid #3c434f;
  border-radius: 3px;
  color: var(--muted);
  font-size: 11.5px;
  white-space: nowrap;
}
/* The analysis board: the engine's score and line above the move list. */
.match-game.analysing .tutorial { flex: 0 0 auto; padding-top: 12px; }
.tutorial-actions:not(:has(> :not([hidden]))) { display: none; }
.tutorial {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}
.tutorial[hidden] { display: none; }
.tutorial-step { margin: 0; color: var(--muted); font-size: 12px; letter-spacing: .06em; text-transform: uppercase; }
.match-panel .tutorial h2 { margin: 0; font: 600 18px/1.25 var(--sans); }
.tutorial-text p { margin: 0 0 8px; color: #c9d0da; font-size: 14px; line-height: 1.5; }
.tutorial-text p:last-child { margin-bottom: 0; }
.tutorial-task { margin: 0; padding: 8px 10px; border-left: 2px solid var(--accent); background: #b9cae312; font-size: 14px; line-height: 1.45; }
.tutorial-task[hidden] { display: none; }
.tutorial-feedback { margin: 0; padding: 8px 10px; border-radius: 3px; font-size: 14px; line-height: 1.45; }
.tutorial-feedback.pass { background: #2c4842; color: #c9f2eb; }
.tutorial-feedback.fail { background: #4a302a; color: #f4cdb8; }
.tutorial-feedback.info { background: #2a3850; color: #d4e0f0; }
/* After a puzzle: the engine's score and best line for the position on screen. */
.puzzle-analysis { padding: 8px 10px; border: 1px solid var(--line); border-radius: 3px; background: #262a31; }
.puzzle-analysis[hidden] { display: none; }
.puzzle-analysis.pending .engine-line-head { margin: 0; }
/* A finished puzzle: turns ahead of the board, which Right plays again. */
.record-cell > button.ahead { opacity: .5; }
.puzzle-filter { display: flex; align-items: center; gap: 8px; margin: 0; color: var(--muted); font-size: 13px; }
.puzzle-filter[hidden] { display: none; }
.puzzle-filter select {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 30px;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: #262a31;
  color: var(--text);
  font: 13px var(--sans);
}
.tutorial-actions { position: sticky; bottom: 0; display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; padding: 6px 0 2px; background: #202328; }
.tutorial-actions .button, .tutorial-actions .primary-button { min-height: 32px; padding: 4px 11px; border-radius: 3px; font-size: 13px; }
.tutorial-actions .button { border: 1px solid var(--line); }
.tutorial-actions .button[aria-pressed=true] { background: #333b46; border-color: var(--accent); color: #d9e3f1; }
.tutorial-actions .tutorial-exit { margin-left: auto; }
.tutorial-actions [hidden] { display: none; }
.board-record { overflow: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: #515964 transparent; }
.board-record .record-row { grid-template-columns: 23px 1fr 1fr; gap: 2px; min-height: 29px; }
.board-record .empty-record { margin: 0; }
.record-cell > button { width: 100%; padding: 4px; text-align: left; font-size: 14px; }
.record-cell > button:hover, :is(.record-line, .record-nested) > button:hover { background: #313841; }
.record-cell > button[aria-current=step], :is(.record-line, .record-nested) > button[aria-current=step] { background: #373f4b; color: #dee8f5; }
/* Side lines tried on the analysis board, under the move they replace; a line inside a line sits in brackets. */
.record-gap { padding: 4px; color: var(--muted); }
.record-lines { margin: 1px 0 4px 23px; padding: 3px 0 3px 8px; border-left: 2px solid #3d4550; }
.record-line { font-size: 13px; line-height: 1.7; }
.record-line + .record-line { margin-top: 2px; }
:is(.record-line, .record-nested) > button { padding: 1px 4px; border-radius: 3px; font-size: 13px; }
:is(.record-line, .record-nested) > button.ahead { opacity: .5; }
:is(.record-line, .record-nested) > .line-number { margin: 0 1px 0 3px; font-size: 12px; }
.record-nested::before { content: "("; color: var(--muted); }
.record-nested::after { content: ")"; color: var(--muted); }
/* How the game ended, closing the move list. */
.record-result { margin: 5px 0 2px; padding: 5px 0 0 4px; border-top: 1px solid var(--line); color: #c9d0da; font-size: 13px; font-variant-numeric: tabular-nums; }
/* The game review's marks on a move: ?! inaccuracy, ? mistake, ?? blunder. */
.move-mark { margin-left: 3px; font-weight: 700; }
.move-mark.inaccuracy, .record-note.inaccuracy b, .retro-slip.inaccuracy, .retro-verdict.inaccuracy { color: #e6d27a; }
.move-mark.mistake, .record-note.mistake b, .retro-slip.mistake, .retro-verdict.mistake { color: #f0a85e; }
.move-mark.blunder, .record-note.blunder b, .retro-slip.blunder, .retro-verdict.blunder { color: #f2806a; }
/* Praise, as chess.com gives it: ★ the engine's own move, ! a great one (the only good move), !! a brilliant one. */
.move-mark.best { color: #8fbf5a; font-size: .82em; font-weight: 400; }
.move-mark.great, .record-note.great b { color: #7fb2e5; }
.move-mark.brilliant, .record-note.brilliant b { color: #3fd0bd; }
/* Over the board on the analysis board: what the review made of the turn just played. */
.move-class { padding: 0 8px 1px; border-radius: 99px; font-weight: 600; letter-spacing: .01em; animation: move-class .4s cubic-bezier(.3, 1.6, .5, 1); }
.move-class.brilliant { background: #3fd0bd2b; color: #6fe6d6; }
.move-class.great { background: #7fb2e52b; color: #a6caf0; }
.move-class.best { background: #8fbf5a24; color: #aed38a; }
.move-class.inaccuracy { background: #e6d27a24; color: #eedd96; }
.move-class.mistake { background: #f0a85e26; color: #f4bd85; }
.move-class.blunder { background: #f2806a2b; color: #f6a191; }
@keyframes move-class { from { opacity: 0; transform: scale(.7); } }
@media (prefers-reduced-motion: reduce) { .move-class { animation: none; } }
/* Under a reviewed slip in the move list: what it was, and the engine's turn, which plays on the board. */
.record-note { margin: 0 0 5px 23px; padding: 1px 0 2px 8px; border-left: 2px solid #3d4550; color: var(--muted); font-size: 12.5px; line-height: 1.5; }
.record-note.inaccuracy { border-left-color: #e6d27a88; }
.record-note.mistake { border-left-color: #f0a85e88; }
.record-note.blunder { border-left-color: #f2806a88; }
.record-note.great { border-left-color: #7fb2e588; }
.record-note.brilliant { border-left-color: #3fd0bd88; }
.record-note b { font-weight: 600; }
.record-note button { padding: 0 4px; border-radius: 3px; color: #d5deeb; font-size: 12.5px; white-space: nowrap; }
.record-note button:hover { background: #2c4842; color: #c9f2eb; }
/* While the board is at a slip being solved, the notes that name the better move go. */
.retro-solving .record-note { display: none; }
/* Learning from a reviewed game's slips, in the analysis panel. */
.retro { display: grid; gap: 8px; padding: 10px 11px 11px; border: 1px solid var(--line); border-radius: 3px; background: #262a31; }
.retro[hidden] { display: none; }
.retro-head { display: flex; justify-content: space-between; gap: 8px; margin: 0; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.retro-head span:first-child { color: #d9dee6; font-weight: 600; }
.retro-move { margin: 0; color: #c9d0da; font-size: 14px; line-height: 1.4; }
.retro-slip { font-weight: 700; }
.retro .tutorial-feedback { padding: 7px 9px; font-size: 13.5px; }
.retro-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.retro-actions > * { min-height: 30px; padding: 3px 10px; border-radius: 3px; font-size: 13px; }
.retro-actions .button { border: 1px solid var(--line); }
.retro-actions .retro-exit { margin-left: auto; }
.retro-actions [hidden] { display: none; }

/* The game review, under the board on the analysis board while there is one to show. --under is the height it
   takes from the board's view. */
.match-game { --under: 0px; }
.match-game.review-open { --under: 246px; }
.review {
  position: absolute;
  left: 0;
  right: var(--rail);
  bottom: 0;
  height: var(--under);
  display: flex;
  flex-direction: column;
  padding: 0 18px 0 22px;
  border-top: 1px solid var(--line);
  background: #1e2126;
  container-type: inline-size;
  font-variant-numeric: tabular-nums;
}
.review[hidden] { display: none; }
.review-head { flex: 0 0 auto; display: flex; align-items: center; gap: 12px; height: 51px; }
.review-head h2 { margin: 0; font: 600 15px var(--sans); white-space: nowrap; }
.review-status { flex: 1 1 auto; min-width: 0; margin: 0; overflow: hidden; color: var(--muted); font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.review-head .review-deeper { flex: 0 0 auto; min-height: 30px; padding: 3px 14px; border: 1px solid var(--line); border-radius: 3px; font-size: 13px; }
.review-fold { display: grid; place-items: center; flex: 0 0 auto; width: 30px; height: 30px; margin-right: -6px; border-radius: 3px; color: var(--muted); }
.review-fold:hover { background: #313841; color: var(--text); }
.review-fold svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; transition: transform .2s; }
.review-body { flex: 1 1 auto; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 24px; padding-bottom: 14px; }
/* White's chances through the game: light above the middle line for White, dark below it for Black. */
.review-graph { position: relative; min-width: 0; overflow: hidden; border: 1px solid #3a4049; border-radius: 3px; background: #2c323b; cursor: pointer; touch-action: none; }
.review-graph svg { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }
.review-white { fill: #e9e0c3; }
.review-black { fill: #111317; }
.review-line { fill: none; stroke: #d4a64f; stroke-width: 1.4; stroke-linejoin: round; }
.review-mid { stroke: #8e97a3; stroke-opacity: .5; stroke-dasharray: 3 3; }
.review-divider { stroke: #8a94a1; stroke-opacity: .8; }
.review-phase { pointer-events: none; }
.review-phase rect { fill: #1b1e23; fill-opacity: .82; }
.review-phase text { fill: #b9c1cc; font: 500 10.5px var(--sans); letter-spacing: .03em; }
.review-now { stroke: #86d0c6; stroke-width: 2; }
.review-hover { stroke: #f0efe4; stroke-opacity: .5; }
.review-dot { stroke: #14171b; stroke-width: 1.5; }
.review-dot.inaccuracy { fill: #e6d27a; }
.review-dot.mistake { fill: #f0a85e; }
.review-dot.blunder { fill: #f2806a; }
.review-dot.great { fill: #7fb2e5; }
.review-dot.brilliant { fill: #3fd0bd; }
.review-tip { position: absolute; top: 6px; margin: 0; padding: 2px 8px; border: 1px solid #4a515c; border-radius: 3px; background: #17191def; color: #e8ecf2; font-size: 12px; white-space: nowrap; pointer-events: none; }
.review-tip-score { margin-left: 8px; color: var(--muted); }
/* A card per side, as lichess sets them out: slips on the left, accuracy by phase on the right. */
.review-sides { display: grid; grid-template-columns: repeat(2, auto); gap: 0 30px; align-content: start; }
.review-side { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.review-side h3 { display: flex; align-items: center; gap: 7px; margin: 0; font: 600 14px/1.5 var(--sans); white-space: nowrap; }
.review-side h3 small { color: var(--muted); font-size: 12px; font-weight: 400; }
.review-accuracy { margin-left: auto; padding-left: 14px; color: var(--muted); font-size: 12px; font-weight: 400; }
.review-accuracy b { color: var(--text); font-size: 17px; font-weight: 700; }
.review-stats { display: grid; grid-template-columns: auto auto; gap: 0 20px; color: #c9d0da; font-size: 13px; line-height: 1.55; white-space: nowrap; }
.review-stats b { display: inline-block; min-width: 2.3em; font-weight: 700; text-align: right; }
.review-stats .short { display: none; }
.review-count { padding: 0; color: inherit; text-align: left; }
.review-count:hover:enabled { color: var(--text); text-decoration: underline; text-underline-offset: 3px; }
.review-count:disabled { opacity: 1; color: #7d8590; }
.review-count.inaccuracy b { color: #e6d27a; }
.review-count.mistake b { color: #f0a85e; }
.review-count.blunder b { color: #f2806a; }
.review-count.great b { color: #7fb2e5; }
.review-count.brilliant b { color: #3fd0bd; }
.review-count.best b { color: #8fbf5a; }
.review-count:disabled b { color: #6f7885; }
/* Praise above the slips, in one row. */
.review-praise { display: flex; gap: 14px; font-size: 13px; line-height: 1.55; white-space: nowrap; color: #c9d0da; }
.review-praise b { font-weight: 700; }
.review-praise .short { display: none; }
.review-phase-score b.great { color: #8fd18a; }
.review-phase-score b.good { color: #86c5e6; }
.review-phase-score b.fair { color: #e6d27a; }
.review-phase-score b.poor { color: #f0a85e; }
.review-phase-score b.bad { color: #f2806a; }
.review-learn { min-height: 30px; margin-top: 3px; padding: 3px 12px; border-radius: 3px; font-size: 13px; }
.review-learn.button { border: 1px solid var(--line); }
.review-learn .short { display: none; }
/* Short windows: a tighter review, so the board keeps its room. */
@media (max-height: 800px) and (min-width: 721px) {
  .match-game.review-open { --under: 210px; }
  .review-head { height: 43px; }
  .review-body { padding-bottom: 10px; }
  .review-side { gap: 4px; }
  .review-stats, .review-praise { line-height: 1.38; }
  .review-learn { min-height: 27px; margin-top: 1px; padding-block: 2px; }
}
/* Narrower: the phases go, and each card is a column of slips. */
@container (max-width: 1000px) {
  .review-stats { grid-template-columns: auto; }
  .review-phase-score { display: none; }
  .review-sides { gap: 0 22px; }
}
/* Phones: the graph above, and a line per side beneath it. */
@container (max-width: 640px) {
  .review-body { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; gap: 7px; padding-bottom: 8px; }
  .review-sides { grid-template-columns: minmax(0, 1fr); gap: 3px; }
  .review-side { flex-direction: row; align-items: center; gap: 10px; }
  .review-side h3 { flex: 0 0 auto; min-width: 9.5em; font-size: 13px; }
  .review-side h3 small { display: none; }
  .review-accuracy { padding-left: 4px; }
  .review-accuracy b { font-size: 14px; }
  .review-accuracy .long { display: none; }
  .review-stats { display: flex; gap: 8px; font-size: 12px; }
  .review-stats b { min-width: 0; }
  .review-stats :is(.long, .review-phase-score) { display: none; }
  .review-stats .short { display: inline; margin-left: 1px; font-weight: 700; }
  .review-praise { order: 1; gap: 8px; font-size: 12px; }
  .review-stats { order: 2; }
  .review-learn { order: 3; }
  .review-praise .long { display: none; }
  .review-praise .short { display: inline; margin-left: 1px; font-weight: 700; }
  .review-count.great .short { color: #7fb2e5; }
  .review-count.brilliant .short { color: #3fd0bd; }
  .review-count.best .short { color: #8fbf5a; }
  .review-acpl { display: none; }
  .review-count.inaccuracy .short { color: #e6d27a; }
  .review-count.mistake .short { color: #f0a85e; }
  .review-count.blunder .short { color: #f2806a; }
  .review-count:disabled .short { color: #6f7885; }
  .review-acpl .short { color: var(--muted); font-weight: 400; }
  .review-learn { min-height: 26px; margin: 0 0 0 auto; padding: 2px 9px; font-size: 12px; }
  .review-learn .long { display: none; }
  .review-learn .short { display: inline; }
}
.match-panel #watch-transport {
  position: static;
  transform: none;
  display: grid;
  grid-template-columns: repeat(4, 32px) 1fr;
  align-items: center;
  max-width: none;
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  padding: 7px 0 0;
}
.match-panel #watch-transport button { width: 100%; }
.match-panel #watch-timeline { width: 100%; grid-area: 1 / 1 / auto / -1; margin: 0; }
.match-panel #watch-progress { text-align: center; }
/* The analysis board also plays its line: the speed sits beside the timeline, play between back and forward. */
.match-game.analysing .match-panel #watch-transport { grid-template-columns: repeat(5, minmax(0, 32px)) minmax(40px, 1fr); }
.match-game.analysing .match-panel #watch-timeline { grid-area: 1 / 1 / auto / 6; }
.match-game.analysing .match-panel #watch-speed { grid-area: 1 / 6; justify-self: end; width: auto; height: 24px; }
/* Away from the live position, the way back to it stands out. */
.match-panel #watch-last.behind { background: var(--accent); color: #21252b; }
@media (max-width: 720px) and (orientation: portrait), (max-width: 540px) {
  .match-game { --dock: calc(166px + env(safe-area-inset-bottom)); }
  .match-game .viewport { right: 0; bottom: calc(var(--dock) + var(--under)); }
  .match-game .notice { left: 50%; bottom: calc(var(--dock) + var(--under) + 58px); }
  .match-game .board-tools { left: max(6px, env(safe-area-inset-left)); bottom: calc(var(--dock) + var(--under) + 8px); display: flex; }
  .board-tools button { width: 36px; height: 36px; }
  .camera-tools { display: flex; padding: 0 0 0 4px; border-top: 0; border-left: 1px solid #3a4250; }
  #piece-style { left: -1px; top: auto; bottom: calc(100% + 8px); width: min(352px, calc(100vw - 12px)); }
  .menu-list { flex-wrap: wrap; padding: 14px 16px 16px; }
  .menu-list button { flex: 1 1 30%; }
  .match-game .menu-toggle { right: max(8px, env(safe-area-inset-right)); }
  /* Phones: one cube and a count per side; the corner title moves below the bar. */
  .match-game .scoreboard { left: 50%; top: max(10px, env(safe-area-inset-top)); }
  .match-game .match-hud { top: calc(max(10px, env(safe-area-inset-top)) + 54px); }
  .score-side { min-width: 0; gap: 6px; padding: 6px 10px; }
  .score-cubes .have + .have { display: none; }
  .score-count { display: inline; }
  .score-turn { min-width: 52px; padding: 4px 10px 5px; }
  .score-turn b { font-size: 21px; }
  .match-panel {
    inset: auto 0 0;
    width: auto;
    height: var(--dock);
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-rows: auto minmax(27px, 1fr) 31px;
    gap: 4px 14px;
    padding: 8px max(12px, env(safe-area-inset-right)) max(4px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
    border: 0;
    border-top: 1px solid var(--line);
  }
  .match-panel h2 { margin-bottom: 2px; font-size: 13px; }
  .stock-row { min-height: 20px; gap: 4px; flex-wrap: nowrap; }
  .stock-row + .stock-row { margin-top: 0; }
  .side-name small, .stock-pips { display: none; }
  .stock-row .side-name { flex: 0 0 auto; }
  .stock-row output { margin-left: 0; order: 2; }
  .stock-row .material { flex: 1 1 auto; order: 3; min-height: 16px; }
  .mat-group img { width: 17px; height: 17px; }
  .mat-group img + img { margin-left: -9px; }
  .panel-history { grid-area: 2 / 1 / auto / -1; flex-direction: row; align-items: center; gap: 9px; min-width: 0; padding-top: 2px; }
  .board-record { display: flex; flex: 1 1 0; min-width: 0; overflow-x: auto; align-items: center; }
  #record-open { position: static; order: 1; flex: none; width: 30px; height: 27px; }
  .board-record .record-row { display: flex; flex-shrink: 0; gap: 3px; padding-right: 8px; }
  .board-record .record-cell > button { white-space: nowrap; }
  .match-panel #watch-transport { grid-column: 1 / -1; grid-template-columns: repeat(4, 30px) 1fr auto; gap: 6px; padding: 0; }
  .match-panel #watch-transport button { height: 30px; width: 30px; }
  .match-game.analysing .match-panel #watch-transport { grid-template-columns: repeat(5, 28px) 1fr auto auto; gap: 5px; }
  .match-game.analysing .match-panel #watch-transport button { width: 28px; }
  .match-game.analysing .match-panel :is(#watch-timeline, #watch-speed) { grid-area: auto; }
  .match-game.analysing .match-panel #watch-transport #watch-speed { width: auto; height: 30px; justify-self: auto; }
  .match-game .eval { right: max(8px, env(safe-area-inset-right)); top: calc(max(10px, env(safe-area-inset-top)) + 112px); bottom: calc(var(--dock) + var(--under) + 14px); }
  .match-panel #watch-timeline { grid-area: auto; }
  /* Online: the game's actions get their own row above the moves. */
  .match-game.online { --dock: calc(232px + env(safe-area-inset-bottom)); }
  .match-game.online .match-panel { grid-template-rows: auto auto minmax(27px, 1fr) 31px; }
  .match-game.online .panel-online { grid-area: 2 / 1 / auto / -1; gap: 5px; }
  .match-game.online .panel-history { grid-row: 3; }
  .score-clock { min-width: 44px; padding: 2px 4px; font-size: 15px; }
  .match-game.online .score-side { gap: 5px; padding-inline: 7px; }
  /* The lit clock shows whose turn it is, which leaves room for the menu button; the wider bar centres
     in the space left of that button. */
  .match-game.online .score-side .turn-token { display: none; }
  .match-game.online .scoreboard { left: calc((100% - 52px - env(safe-area-inset-right)) / 2); }
  .match-game.online .score-turn { min-width: 44px; padding-inline: 8px; }
  /* A finished game against the computer: rematch and analysis side by side. */
  .rematch-box { grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 0; }
  .online-actions.game-actions button { flex: 1 1 0; justify-content: center; padding: 5px 6px; }
  /* Side lines and the result run on in the one row of moves. */
  .board-record :is(.record-lines, .record-line, .record-result) { display: flex; flex-shrink: 0; align-items: center; margin: 0; white-space: nowrap; }
  .board-record .record-lines { gap: 8px; margin-right: 8px; padding: 0 8px; border-inline: 2px solid #3d4550; }
  .board-record .record-result { padding: 0 8px 0 10px; border-top: 0; border-left: 1px solid var(--line); }
  .rematch-sides { grid-column: 1 / -1; }
  .rematch-sides button { min-height: 30px; }
  .rematch-box :is(.primary-button, .button) { min-height: 32px; padding: 4px 6px; font-size: 13px; }
  .rematch-box .long { display: none; }
  /* The analysis board: the engine's line gets its own row above the moves. */
  .match-game.analysing { --dock: calc(280px + env(safe-area-inset-bottom)); }
  .match-game.analysing .match-panel { grid-template-rows: auto auto minmax(27px, 1fr) 31px; }
  .match-game.analysing .match-panel .tutorial { grid-area: 2 / 1 / auto / -1; gap: 6px; padding-top: 6px; overflow: hidden; }
  .match-game.analysing .tutorial-actions { margin-top: 0; padding: 0; }
  .match-game.analysing .tutorial-actions > * { flex: 1 1 auto; justify-content: center; padding-inline: 6px; }
  /* The game review sits on the dock, under the board. */
  .match-game.review-open { --under: 200px; }
  .review { right: 0; bottom: var(--dock); padding: 0 max(12px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left)); }
  .review-head { gap: 8px; height: 45px; }
  .review-head h2 { font-size: 14px; }
  .review-status { font-size: 12px; }
  .review-head .review-deeper { padding: 3px 10px; }
  .board-record .record-note { display: none; }
  /* Learning from mistakes: the dock grows for the task, and the review makes way for the board. */
  .match-game.analysing.retro-on { --dock: calc(392px + env(safe-area-inset-bottom)); }
  .match-game.retro-on.review-open { --under: 0px; }
  .match-game.retro-on .review { display: none !important; }
  .retro { gap: 6px; padding: 8px 10px; }
  .retro .tutorial-feedback { padding: 5px 8px; font-size: 13px; }
  .match-game.analysing .panel-history { grid-row: 3; }
  .match-game.analysing .engine-line-moves { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .match-game.tutoring { --dock: min(54dvh, 440px); }
  .match-panel .tutorial { grid-column: 1 / -1; grid-row: 2 / -1; padding-top: 8px; }
  .match-game.tutoring.puzzling { --dock: min(44dvh, 340px); }
  .match-game.tutoring.studying { --dock: min(54dvh, 440px); }
  .match-game.tutoring.studying .tutorial { max-height: none; }
  .match-game.tutoring.puzzling .match-panel .tutorial { grid-row: 2; }
  .match-game.tutoring.puzzling .panel-history { display: none; }
}

/* A Gemini match on the analysis board: the model's reasoning in a reading rail between the board and the
   panel, a sheet above the panel on phones. Everything placed beside the board makes room through --rail. */
.match-game.with-reasoning { --panel: clamp(202px, 19vw, 264px); --reading: clamp(300px, 27vw, 440px); --rail: calc(var(--panel) + var(--reading)); }
.match-game.with-reasoning .match-panel { width: var(--panel); }
.match-game.zen .reasoning { display: none !important; }
.reasoning {
  position: absolute;
  inset: 0 var(--panel) 0 auto;
  width: var(--reading);
  display: flex;
  flex-direction: column;
  background: #1e2126;
  border-left: 1px solid var(--line);
}
.reasoning-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: max(18px, env(safe-area-inset-top)) 16px 12px 20px;
  border-bottom: 1px solid var(--line);
}
.reasoning-kicker { margin: 0 0 4px; color: var(--muted); font-size: 12px; letter-spacing: .02em; }
.reasoning-head h2 {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 10px;
  margin: 0;
  font: 400 27px/1.12 var(--serif);
  letter-spacing: -.04em;
}
.reasoning-state {
  padding: 1px 8px 2px;
  border: 1px solid #626c7a;
  border-radius: 99px;
  color: #b3bfcf;
  font: 500 11px/1.4 var(--sans);
  letter-spacing: .05em;
  text-transform: uppercase;
}
.reasoning-state.upcoming { border-color: #86d0c6; color: #a9e2da; }
.reasoning-nav { display: flex; align-items: center; gap: 1px; flex-shrink: 0; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.reasoning-nav button { display: grid; place-items: center; width: 32px; height: 32px; padding: 0; border-radius: 3px; }
.reasoning-nav button:hover:enabled { background: #313841; }
.reasoning-nav svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.reasoning-nav span { min-width: 44px; text-align: center; }
.reasoning-summary { padding: 13px 20px 12px; border-bottom: 1px solid var(--line); background: #22262b; }
.reasoning-quote { margin: 0; color: #dfe7f2; font: italic 400 18px/1.32 var(--serif); }
.reasoning-quote::before { content: "“"; }
.reasoning-quote::after { content: "”"; }
.reasoning-meta { margin: 5px 0 0; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.reasoning-eval { margin: 5px 0 0; color: #b3bfcf; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.reasoning-eval.pending { color: var(--muted); }
.reasoning-eval:empty { display: none; }
.reasoning-eval.inaccuracy strong { color: #e6d27a; }
.reasoning-eval.mistake strong { color: #f0a85e; }
.reasoning-eval.blunder strong { color: #f2806a; }
.reasoning-body {
  flex: 1 1 0;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 16px 20px 28px;
  color: #cbd1da;
  font-size: 14px;
  line-height: 1.62;
  -webkit-user-select: text;
  user-select: text;
  scrollbar-width: thin;
  scrollbar-color: #515964 transparent;
  outline: none;
}
.reasoning-body:focus-visible { box-shadow: inset 0 0 0 2px #bac9df55; }
.reasoning-body p { margin: 0 0 11px; }
.reasoning-body ul, .reasoning-body ol { margin: 0 0 11px; padding-left: 20px; }
.reasoning-body h3 { margin: 16px 0 6px; color: #dfe7f2; font: 600 14px/1.35 var(--sans); }
.reasoning-body strong { color: #dfe7f2; font-weight: 600; }
.reasoning-empty { color: var(--muted); }
.step-label {
  margin: 0 0 7px;
  color: #8c97a6;
  font: 600 11px/1.3 var(--sans);
  letter-spacing: .08em;
  text-transform: uppercase;
}
.thought { margin: 0 0 16px; padding-left: 13px; border-left: 2px solid #3a414a; }
.thought > p:last-child, .reply > p:last-child { margin-bottom: 0; }
.reasoning-body code {
  padding: 1px 5px;
  border-radius: 3px;
  background: #2b3037;
  color: #d6e0ef;
  font: 500 12.5px/1.2 "Cascadia Mono", Consolas, ui-monospace, monospace;
  white-space: nowrap;
}
.reasoning-body code[data-squares]:not([data-squares=""]) { cursor: help; box-shadow: inset 0 -1px #86d0c666; }
.reasoning-body code[data-squares]:not([data-squares=""]):hover { background: #2c4842; color: #c9f2eb; }
.call-card { margin: 0 0 8px; padding: 10px 12px; border: 1px solid #48505c; border-radius: 3px; background: #252a30; }
.call-card.other { border-color: #8e7444; background: #33301f; }
.call-move { margin: 0 !important; }
.call-move code { font-size: 14px; }
.call-summary { margin: 5px 0 0 !important; color: var(--muted); font-size: 13px; }
.tool-result { margin: 0 0 16px !important; color: #98afcf; font-size: 13px; }
.tool-result.failed { color: #f2ce8a; }
.reply { margin-top: 4px; padding-top: 12px; border-top: 1px solid var(--line); color: #b8bfc9; }
/* Between the board and a wide rail, the corner title has no room beside the bar: it moves below it, as on phones. */
@media (min-width: 721px) and (max-width: 1700px) {
  .match-game.with-reasoning .match-hud { top: calc(max(18px, env(safe-area-inset-top)) + 62px); }
}
@media (max-width: 720px) and (orientation: portrait), (max-width: 540px) {
  .match-game.with-reasoning { --sheet: min(30dvh, 280px); }
  .match-game.with-reasoning:has(#review:not([hidden])) { --sheet: min(25dvh, 230px); }
  .match-game.with-reasoning .match-panel { width: auto; }
  .match-game.with-reasoning .viewport { bottom: calc(var(--dock) + var(--sheet) + var(--under)); }
  .match-game.with-reasoning .notice { bottom: calc(var(--dock) + var(--sheet) + var(--under) + 58px); }
  .match-game.with-reasoning .board-tools { bottom: calc(var(--dock) + var(--sheet) + var(--under) + 8px); }
  .match-game.with-reasoning .eval { bottom: calc(var(--dock) + var(--sheet) + var(--under) + 14px); }
  .match-game.with-reasoning .review { bottom: calc(var(--dock) + var(--sheet)); }
  .reasoning { inset: auto 0 var(--dock); width: auto; height: var(--sheet); border-left: 0; border-top: 1px solid var(--line); }
  .reasoning-head { padding: 10px 10px 8px 16px; }
  .reasoning-head h2 { font-size: 22px; }
  .reasoning-summary { padding: 9px 16px; }
  .reasoning-quote { font-size: 16px; }
  .reasoning-body { padding: 12px 16px 20px; font-size: 14px; }
}
