/* Chat tools, games and templates inside the conversation (chat-tools-ui.js). Built on tokens.css: corners and type
   from the --ds scale, colours from the theme. A special message is a calm card in the bubble, whoever sent it. */

/* ── The bubble of a special message ───────────────────────────────────────────────────────────── */
.chat-bubble:is([data-kind="interactive"], [data-kind="templates"]) .chat-lc-text { display: none; }
.chat-bubble:is([data-kind="interactive"], [data-kind="templates"]) .chat-lc-bubble {
  /* A grid, not the flex row of a text bubble: square cells of a board get their height from the width. */
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--ds-space-2);
  width: min(100%, 20rem);
  max-width: min(92%, 22rem);
  padding: var(--ds-space-3);
  border-radius: var(--ds-radius-2xl);
  background: color-mix(in srgb, var(--lc-text) 7%, transparent);
  color: var(--lc-text);
  white-space: normal;
}
.chat-bubble:is([data-kind="interactive"], [data-kind="templates"]) .chat-lc-meta {
  justify-self: end;
  margin-top: calc(-1 * var(--ds-space-1));
  transform: none;
}
.chat-lc-interactive { display: grid; gap: var(--ds-space-2); min-width: 0; }
.ct-skeleton {
  height: 3.25rem;
  border-radius: var(--ds-radius-lg);
  background: linear-gradient(90deg, var(--lc-control), color-mix(in srgb, var(--lc-text) 10%, transparent), var(--lc-control));
  background-size: 200% 100%;
  animation: ct-shimmer 1.2s linear infinite;
}
@keyframes ct-shimmer { to { background-position: -200% 0; } }

/* Templates sent together: one card, a block per template, a soft ornament line between them. */
.chat-lc-template-block { display: grid; gap: var(--ds-space-1); padding: var(--ds-space-1) 0; }
.chat-lc-template-block strong { font: 700 var(--ds-fs-control)/1.3 var(--lc-font); }
.chat-lc-template-block p { margin: 0; color: color-mix(in srgb, var(--lc-text) 86%, transparent); font: 400 var(--ds-fs-control)/1.45 var(--lc-font); white-space: pre-wrap; }
.chat-lc-template-block + .chat-lc-template-block { position: relative; padding-top: var(--ds-space-3); }
.chat-lc-template-block + .chat-lc-template-block::before {
  content: '';
  position: absolute;
  top: 0;
  right: 12%;
  left: 12%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--lc-hairline) 20%, var(--lc-hairline) 46%, transparent 48%, transparent 52%, var(--lc-hairline) 54%, var(--lc-hairline) 80%, transparent);
}
.chat-lc-template-block + .chat-lc-template-block::after {
  content: '';
  position: absolute;
  top: -2px;
  left: calc(50% - 2.5px);
  width: 5px;
  height: 5px;
  background: var(--lc-hairline);
  rotate: 45deg;
}

/* ── Small common parts ─────────────────────────────────────────────────────────────────────────── */
.ct-btn {
  display: inline-flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  gap: var(--ds-space-2);
  box-sizing: border-box;
  min-height: 40px;
  padding: 0 var(--ds-space-3);
  border: 0;
  border-radius: var(--ds-radius-control);
  background: var(--lc-control);
  color: var(--lc-text);
  cursor: pointer;
  font: 700 var(--ds-fs-body)/1.1 var(--lc-font);
  transition: background-color var(--ds-dur-fast) ease, opacity var(--ds-dur-fast) ease;
}
.ct-btn:hover:not(:disabled) { background: var(--lc-control-hover, var(--lc-control)); }
.ct-btn:disabled, .ct-btn[aria-disabled="true"] { cursor: default; opacity: var(--ds-disabled-opacity); }
.ct-btn--primary { background: var(--lc-button); color: var(--lc-on-button); }
.ct-btn--primary:hover:not(:disabled) { background: color-mix(in srgb, var(--lc-button) 88%, var(--lc-text)); }
.ct-btn:focus-visible, .ct-icon-btn:focus-visible, .ct-cell:focus-visible, .ct-card:focus-visible, .ct-chip:focus-visible,
.ct-quiz-option:focus-visible, .ct-hint:focus-visible, .ct-link:focus-visible, .ct-seg-btn:focus-visible, .ct-star:focus-visible {
  outline: 2px solid var(--lc-accent);
  outline-offset: 2px;
}
.ct-send { width: 100%; min-height: var(--ds-touch); font-size: var(--ds-fs-control); }
.ct-icon-btn {
  position: relative;
  display: grid;
  flex: none;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--lc-muted);
  cursor: pointer;
  transition: background-color var(--ds-dur-fast) ease, color var(--ds-dur-fast) ease;
}
.ct-icon-btn::after { content: ''; position: absolute; inset: calc((var(--ds-touch) - 32px) / -2); }
.ct-icon-btn:hover { background: var(--lc-control); color: var(--lc-text); }
.ct-icon-btn .lc-icon { width: 18px; height: 18px; }
.ct-link {
  min-height: 32px;
  padding: 0 var(--ds-space-1);
  border: 0;
  background: none;
  color: var(--lc-accent);
  cursor: pointer;
  font: 700 var(--ds-fs-body)/1.2 var(--lc-font);
}
.ct-row { display: flex; gap: var(--ds-space-2); }
.ct-muted { color: var(--lc-muted); font: 500 var(--ds-fs-label)/1.35 var(--lc-font); }
.ct-small { margin: 0; font: 500 var(--ds-fs-label)/1.4 var(--lc-font); }
.ct-label { color: var(--lc-muted); font: 700 var(--ds-fs-label)/1.3 var(--lc-font); letter-spacing: .05em; text-transform: uppercase; }
.ct-pill {
  flex: none;
  padding: 3px var(--ds-space-2);
  border-radius: var(--ds-radius-pill);
  background: var(--lc-control);
  color: var(--lc-muted);
  font: 700 var(--ds-fs-micro)/1.2 var(--lc-font);
  white-space: nowrap;
}
.ct-pill[data-tone="accent"] { background: color-mix(in srgb, var(--lc-accent) 22%, transparent); color: var(--lc-text); }
.ct-pill[data-tone="win"] { background: color-mix(in srgb, var(--ds-green) 22%, transparent); color: var(--lc-text); }
.ct-pill[data-tone="lose"] { background: color-mix(in srgb, var(--ds-red) 20%, transparent); color: var(--lc-text); }
.ct-flash {
  margin: 0;
  max-height: 0;
  overflow: hidden;
  color: var(--ds-red);
  font: 600 var(--ds-fs-label)/1.3 var(--lc-font);
  opacity: 0;
  transition: max-height var(--ds-dur) var(--ds-ease-out), opacity var(--ds-dur) ease;
}
.ct-flash.is-on { max-height: 2.6em; opacity: 1; }
/* Until it speaks, the line takes no room, not even the gap of the card. */
.ct-flash:not(.is-on) { margin-top: calc(-1 * var(--ds-space-2)); }
.ct-input {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  min-height: var(--ds-touch);
  padding: 0 var(--ds-space-3);
  border: 0;
  border-radius: var(--ds-radius-control);
  background: var(--ds-surface-inset);
  color: var(--lc-text);
  font: 500 var(--ds-fs-input)/1.3 var(--lc-font);
}
.ct-input:focus-visible { background: var(--ds-control-hover); outline: var(--ds-focus-ring); outline-offset: -2px; }
@media (forced-colors: active) {
  .ct-input { border: 1px solid ButtonText; }
  .ct-input[aria-invalid="true"] { border-style: dashed; }
}
select.ct-input { appearance: none; -webkit-appearance: none; padding-right: var(--ds-space-3); cursor: pointer; }

/* ── Tools in a message ─────────────────────────────────────────────────────────────────────────── */
.ct-tool--timer {
  display: flex;
  align-items: center;
  gap: var(--ds-space-3);
  min-height: 3rem;
}
.ct-tool--timer > .lc-icon { width: 22px; height: 22px; color: var(--lc-muted); }
.ct-tool--timer[data-phase="running"] > .lc-icon { color: var(--lc-accent); animation: ct-hourglass 2.4s var(--ds-ease-spring) infinite; }
@keyframes ct-hourglass { 0%, 70% { rotate: 0deg; } 85%, 100% { rotate: 180deg; } }
.ct-timer-time {
  flex: 1;
  font: 800 calc(var(--ds-fs-hero) * 1.15)/1 var(--lc-font);
  font-variant-numeric: tabular-nums;
  letter-spacing: -.01em;
}
.ct-tool--timer:not([data-phase="running"]) .ct-timer-time { color: var(--lc-muted); font: 700 var(--ds-fs-title)/1.2 var(--lc-font); }
.ct-tool--timer[data-phase="ended"] .ct-timer-time { color: var(--lc-text); animation: ct-pop .4s var(--ds-ease-spring); }
@keyframes ct-pop { 40% { transform: scale(1.06); } }

.ct-tool--random { display: grid; justify-items: center; gap: var(--ds-space-1); padding: var(--ds-space-2) 0; }
.ct-random-range { color: var(--lc-muted); font: 600 var(--ds-fs-label)/1.2 var(--lc-font); font-variant-numeric: tabular-nums; }
.ct-random-value { font: 900 calc(var(--ds-fs-hero) * 1.5)/1.05 var(--lc-font); font-variant-numeric: tabular-nums; }
.ct-random-value.is-spinning { opacity: .55; filter: blur(.5px); }
.ct-random-value.is-landed { animation: ct-pop .45s var(--ds-ease-spring); }

.ct-tool--quiz { display: grid; gap: var(--ds-space-2); }
.ct-quiz-question { margin: 0; font: 700 var(--ds-fs-title)/1.35 var(--lc-font); overflow-wrap: anywhere; }
.ct-quiz-options { display: grid; gap: var(--ds-space-1); }
.ct-quiz-option {
  display: flex;
  align-items: center;
  gap: var(--ds-space-2);
  min-height: var(--ds-touch);
  padding: var(--ds-space-1) var(--ds-space-3) var(--ds-space-1) var(--ds-space-2);
  border: 0;
  border-radius: var(--ds-radius-lg);
  background: var(--lc-control);
  color: var(--lc-text);
  cursor: pointer;
  font: 600 var(--ds-fs-control)/1.3 var(--lc-font);
  text-align: left;
  transition: background-color var(--ds-dur) ease;
}
.ct-quiz-option:disabled { cursor: default; }
.ct-quiz-option:hover:not(:disabled) { background: var(--lc-control-hover, var(--lc-control)); }
.ct-quiz-letter {
  display: grid;
  flex: none;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--lc-text) 10%, transparent);
  font: 800 var(--ds-fs-micro)/1 var(--lc-font);
}
.ct-quiz-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.ct-quiz-count { color: var(--lc-muted); font: 700 var(--ds-fs-label)/1 var(--lc-font); font-variant-numeric: tabular-nums; }
.ct-quiz-option[data-mine] { background: color-mix(in srgb, var(--lc-accent) 22%, transparent); }
.ct-quiz-option[data-mine="right"], .ct-quiz-option[data-correct="true"] { background: color-mix(in srgb, var(--ds-green) 22%, transparent); }
.ct-quiz-option[data-mine="wrong"] { background: color-mix(in srgb, var(--ds-red) 20%, transparent); }
.ct-quiz-option[data-correct="true"] .ct-quiz-letter { background: var(--ds-green); color: var(--lc-bg); }
.ct-tool-foot { display: flex; align-items: center; justify-content: space-between; gap: var(--ds-space-2); min-height: 32px; }

/* ── Games in a message ─────────────────────────────────────────────────────────────────────────── */
.ct-game, .ct-game-body { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--ds-space-2); min-width: 0; }
.ct-game { container: ct-game / inline-size; width: 100%; box-sizing: border-box; }
.ct-game-head {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto auto;
  grid-template-areas: "icon name status expand";
  align-items: center;
  min-height: 32px;
  gap: var(--ds-space-2);
}
.ct-game-head > .lc-icon { grid-area: icon; width: 18px; height: 18px; color: var(--lc-accent); }
.ct-game-name { grid-area: name; min-width: 0; overflow-wrap: anywhere; font: 700 var(--ds-fs-body)/1.25 var(--lc-font); }
.ct-game-head .ct-pill { grid-area: status; justify-self: start; max-width: 100%; box-sizing: border-box; white-space: normal; }
.ct-game-head .ct-expand { grid-area: expand; }
.ct-game .ct-icon-btn, .ct-full-head .ct-icon-btn { width: var(--ds-touch); height: var(--ds-touch); }
.ct-game .ct-icon-btn::after, .ct-full-head .ct-icon-btn::after { content: none; }
@container ct-game (max-width: 19rem) {
  .ct-game-head { grid-template-columns: 18px minmax(0, 1fr) auto; grid-template-areas: "icon name expand" ". status status"; row-gap: var(--ds-space-1); }
}
.ct-game :is(.ct-row, .ct-seg, .ct-tool-foot) { flex-wrap: wrap; min-width: 0; }
.ct-game .ct-row > .ct-btn:not(.ct-promote-piece) { flex: 1 1 min(100%, 6rem); min-width: 0; text-align: center; }
.ct-game .ct-btn { min-width: 0; overflow-wrap: anywhere; }
.ct-game .ct-seg-btn { flex: 1 1 min(100%, 5rem); min-width: 0; white-space: normal; }
.ct-game-note { margin: 0; color: var(--lc-muted); font: 500 var(--ds-fs-label)/1.4 var(--lc-font); overflow-wrap: anywhere; }
.ct-game-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--ds-space-1) var(--ds-space-3);
  padding: var(--ds-space-2);
  border-radius: var(--ds-radius-lg);
  background: var(--lc-control);
  color: var(--lc-muted);
  font: 600 var(--ds-fs-label)/1.3 var(--lc-font);
  font-variant-numeric: tabular-nums;
}
.ct-game-meta > span { min-width: 0; overflow-wrap: anywhere; }
.ct-game-meta .ct-stake { color: var(--lc-text); }
.ct-game-error {
  margin: 0;
  min-width: 0;
  padding: var(--ds-space-2);
  border-radius: var(--ds-radius-lg);
  background: color-mix(in srgb, var(--ds-red) 12%, transparent);
  color: var(--lc-text);
  font: 600 var(--ds-fs-label)/1.4 var(--lc-font);
  overflow-wrap: anywhere;
}
.ct-game-error:empty { block-size: 0; padding: 0; margin-block-end: calc(-1 * var(--ds-space-2)); }
.ct-resign { flex: none; color: var(--lc-muted); font-weight: 600; }
.ct-score { margin: 0; text-align: center; font: 800 var(--ds-fs-heading)/1.1 var(--lc-font); font-variant-numeric: tabular-nums; }
.ct-game[data-status="complete"] .ct-game-body, .chat-lc-interactive[data-state="gone"] .ct-game-body { opacity: .82; }

.ct-grid {
  --gap: 3px;
  display: grid;
  grid-template-columns: repeat(var(--n), minmax(0, 1fr));
  gap: var(--gap);
  width: 100%;
  margin-inline: auto;
}
.ct-cell {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  min-width: 0;
  padding: 0;
  border: 0;
  border-radius: var(--ds-radius-md);
  background: var(--lc-control);
  color: var(--lc-text);
  cursor: pointer;
  transition: background-color var(--ds-dur-fast) ease;
}
.ct-cell:disabled { cursor: default; }
.ct-cell:not(:disabled):hover { background: var(--lc-control-hover, var(--lc-control)); }
.ct-cell .lc-icon { width: 58%; height: 58%; }

.ct-ttt { --gap: 5px; max-width: 12.5rem; }
.ct-ttt .ct-cell { border-radius: var(--ds-radius-lg); font: 700 calc(var(--ds-fs-hero) * 1.3)/1 var(--lc-font); }
.ct-ttt .ct-cell[data-mark] { animation: ct-mark var(--ds-dur) var(--ds-ease-spring); }
.ct-ttt .ct-cell[data-mine="true"] { color: var(--lc-accent); }
.ct-ttt .ct-cell[data-win="true"] { background: color-mix(in srgb, var(--lc-accent) 26%, transparent); }
@keyframes ct-mark { from { transform: scale(.6); opacity: 0; } }

.ct-mines { --gap: 4px; max-width: 18rem; }
.ct-mines .ct-cell[data-open="true"] { background: transparent; box-shadow: inset 0 0 0 1px var(--lc-hairline); }
.ct-mines .ct-cell[data-open="true"]::before { content: ''; width: 22%; aspect-ratio: 1; border-radius: 50%; background: var(--lc-muted); opacity: .5; }
.ct-mines .ct-cell[data-last="true"]::before { background: var(--lc-accent); opacity: 1; }
.ct-mines .ct-cell[data-mine="true"] { background: color-mix(in srgb, var(--ds-red) 24%, transparent); color: var(--ds-red); }
.ct-mines .ct-cell[data-mine="true"]::before { content: none; }
.ct-mines .ct-cell[data-mine="true"][data-open="true"] { background: var(--ds-danger); color: var(--ds-on-danger); }

.ct-sea { --gap: 2px; max-width: 19rem; }
.ct-sea .ct-cell { border-radius: var(--ds-radius-xs); }
.ct-sea .ct-cell[data-ship="true"] { background: color-mix(in srgb, var(--lc-text) 34%, transparent); }
.ct-sea .ct-cell[data-shot="miss"]::before { content: ''; width: 24%; aspect-ratio: 1; border-radius: 50%; background: var(--lc-muted); }
.ct-sea .ct-cell[data-shot="hit"] { background: color-mix(in srgb, var(--ds-red) 70%, transparent); }
.ct-sea .ct-cell[data-shot="hit"]::before { content: '✕'; color: var(--ds-on-danger); font: 800 var(--ds-fs-micro)/1 var(--lc-font); }
.ct-sea .ct-cell[data-last="true"] { box-shadow: 0 0 0 2px var(--lc-accent); z-index: 1; }
.ct-seas { display: grid; gap: var(--ds-space-3); }
.ct-sea-box { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--ds-space-1); min-width: 0; }
.ct-seg { display: flex; gap: 2px; padding: 2px; border-radius: calc(var(--ds-radius-tab) + 2px); background: var(--lc-control); }
.ct-seg-btn {
  flex: 1;
  min-height: 32px;
  border: 0;
  border-radius: var(--ds-radius-tab);
  background: transparent;
  color: var(--lc-muted);
  cursor: pointer;
  font: 700 var(--ds-fs-label)/1 var(--lc-font);
  transition: background-color var(--ds-dur) ease, color var(--ds-dur) ease;
}
.ct-seg-btn[aria-pressed="true"] { background: var(--lc-card, var(--lc-bg)); color: var(--lc-text); }

/* The board of chess and draughts (owner, 2026-11-14): plain light and dark squares, the same in every theme
   and palette, so both colours of pieces read on both; the numbers and the letters stand outside the board. */
.ct-board-frame {
  --ct-light: #e9e8ed;
  --ct-dark: #7b7e8a;
  display: grid;
  grid-template-columns: 1rem minmax(0, 1fr);
  grid-template-rows: auto 1rem;
  gap: 2px var(--ds-space-1);
  width: 100%;
  max-width: 21.25rem;
  margin-inline: auto;
}
.ct-ranks, .ct-files { display: grid; color: var(--lc-muted); font: 700 var(--ds-fs-micro)/1 var(--lc-font); text-align: center; }
.ct-ranks { grid-template-rows: repeat(8, minmax(0, 1fr)); align-items: center; }
.ct-files { grid-column: 2; grid-template-columns: repeat(8, minmax(0, 1fr)); align-items: center; }
/* The backing is the middle of the two shades: where the width does not divide by eight, the hairline between
   two squares is a quiet grey, never the dark of the bubble behind. */
.ct-board8 { --gap: 0; overflow: hidden; max-width: none; margin: 0; border-radius: var(--ds-radius-lg); background: #b2b3bb; }
.ct-board8 .ct-cell { border-radius: 0; background-color: var(--ct-light); }
.ct-board8 .ct-cell[data-dark="true"] { background-color: var(--ct-dark); }
/* What is picked, the last move and where a piece may go lie over the square as a wash, so the square under
   them stays light or dark. */
.ct-board8 .ct-cell[data-picked="true"] { box-shadow: inset 0 0 0 99px color-mix(in srgb, var(--lc-button) 55%, transparent); }
.ct-board8 .ct-cell:not(:disabled):hover { background-color: var(--ct-light); filter: brightness(1.08); }
.ct-board8 .ct-cell[data-dark="true"]:not(:disabled):hover { background-color: var(--ct-dark); }
.ct-stone {
  width: 76%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffffff, #d9d4cb 70%);
  box-shadow: inset 0 -2px 0 rgb(0 0 0 / .18), 0 1px 2px rgb(0 0 0 / .35);
  transition: transform var(--ds-dur) var(--ds-ease-spring);
}
.ct-stone[data-color="b"] { background: radial-gradient(circle at 35% 30%, #5a5a63, #18181b 72%); box-shadow: inset 0 -2px 0 rgb(0 0 0 / .4), 0 1px 2px rgb(0 0 0 / .45); }
.ct-stone[data-king="true"] { box-shadow: inset 0 0 0 3px var(--ds-amber), 0 1px 2px rgb(0 0 0 / .4); }
.ct-board8 .ct-cell[data-picked="true"] .ct-stone { transform: scale(1.08); }
.ct-chess .ct-cell { font: 400 min(calc(var(--ds-fs-heading) * 1.1), 9.5cqi)/1 var(--lc-font); }
.ct-chess .ct-cell[data-side="w"] { color: #ffffff; text-shadow: 0 0 1px #000, 0 0 1px #000, 0 0 2px #000, 0 1px 2px rgb(0 0 0 / .55); }
.ct-chess .ct-cell[data-side="b"] { color: #17171a; text-shadow: 0 0 1px rgb(255 255 255 / .7), 0 0 2px rgb(255 255 255 / .35); }
.ct-promote { flex-wrap: wrap; }
.ct-promote-piece { flex: 0 0 var(--ds-touch); padding: 0; font: 400 var(--ds-fs-heading)/1 var(--lc-font); }

.ct-card {
  position: relative;
  display: inline-grid;
  place-items: center;
  align-content: center;
  width: 2.5rem;
  height: 3.5rem;
  padding: 0;
  border: 0;
  border-radius: var(--ds-radius-md);
  background: #fbfaf7;
  box-shadow: 0 1px 2px rgb(0 0 0 / .35);
  color: #1a1a1d;
  cursor: pointer;
  line-height: 1;
  transition: transform var(--ds-dur-fast) var(--ds-ease-out);
}
.ct-card[data-red="true"] { color: #c62a36; }
.ct-card[data-danger="true"] { color: #151518; }
.ct-card b { font: 800 var(--ds-fs-control)/1 var(--lc-font); }
.ct-card i { font: 400 var(--ds-fs-title)/1 var(--lc-font); font-style: normal; }
button.ct-card:not(:disabled):hover { transform: translateY(-4px); }
button.ct-card:disabled { cursor: default; filter: saturate(.7) brightness(.92); }
.ct-card[data-danger="true"] { box-shadow: 0 0 0 2px var(--ds-red), 0 0 14px -2px var(--ds-red); }
.ct-durak-info { display: flex; align-items: center; justify-content: space-between; gap: var(--ds-space-2); }
.ct-trump { display: inline-flex; align-items: center; gap: var(--ds-space-1); }
.ct-trump b { font: 400 var(--ds-fs-heading)/1 var(--lc-font); }
.ct-trump[data-red="true"] b { color: var(--ds-red); }
.ct-game--durak, .ct-game--durak .ct-game-body, .ct-game--durak .ct-table, .ct-game--durak .ct-hand { min-width: 0; max-width: 100%; box-sizing: border-box; }
.ct-game--durak .ct-game-body { display: grid; gap: var(--ds-space-3); }
.ct-durak-info { padding: var(--ds-space-2) 0; border-bottom: 1px solid var(--lc-hairline); }
.ct-table { display: flex; flex-wrap: wrap; align-items: center; gap: var(--ds-space-2); min-height: 4rem; width: 100%; padding: var(--ds-space-2); border: 1px solid color-mix(in srgb, var(--ds-green) 22%, var(--lc-hairline)); border-radius: var(--ds-radius-lg); background: color-mix(in srgb, var(--ds-green) 6%, transparent); }
.ct-pair { position: relative; flex: 0 0 3.25rem; width: 3.25rem; height: 4rem; }
.ct-pair > .ct-card { position: absolute; top: 0; left: 0; }
.ct-pair > .ct-cover { top: .5rem; left: .75rem; rotate: 12deg; }
.ct-game--durak .ct-hand { display: flex; flex-wrap: nowrap; gap: var(--ds-space-1); width: 100%; max-width: 100%; overflow-x: auto; overflow-y: hidden; padding: var(--ds-space-1) 2px var(--ds-space-2); }
.ct-game--durak .ct-hand .ct-card { flex: 0 0 2.5rem; }

.ct-danger { display: flex; align-items: center; gap: var(--ds-space-4); }
.ct-deck {
  display: grid;
  place-items: center;
  align-content: center;
  width: 3.5rem;
  height: 4.75rem;
  border-radius: var(--ds-radius-md);
  background: repeating-linear-gradient(45deg, color-mix(in srgb, var(--lc-accent) 30%, transparent) 0 4px, color-mix(in srgb, var(--lc-accent) 18%, transparent) 4px 8px);
  box-shadow: 3px 3px 0 color-mix(in srgb, var(--lc-text) 12%, transparent), 6px 6px 0 color-mix(in srgb, var(--lc-text) 6%, transparent);
}
.ct-deck b { font: 800 var(--ds-fs-heading)/1 var(--lc-font); }
.ct-danger-last { display: flex; align-items: center; gap: var(--ds-space-2); }
.ct-danger-last .ct-card.is-drawn { animation: ct-draw var(--ds-dur-sheet) var(--ds-ease-out); }
@keyframes ct-draw { from { transform: translateX(-1.5rem) rotate(-8deg); opacity: 0; } }

.ct-mouse-field {
  display: grid;
  place-items: center;
  height: 7.5rem;
  border-radius: var(--ds-radius-lg);
  background: radial-gradient(ellipse 40% 26% at 50% 78%, color-mix(in srgb, var(--lc-text) 26%, transparent), transparent 70%), var(--lc-control);
  overflow: hidden;
}
.ct-mouse { position: relative; width: 5rem; height: 5rem; padding: 0; border: 0; border-radius: 50%; background: transparent; cursor: pointer; }
.ct-mouse:disabled { cursor: default; }
.ct-mouse-body {
  position: absolute;
  bottom: 12%;
  left: 18%;
  width: 64%;
  height: 46%;
  border-radius: 50% 50% 44% 44%;
  background: var(--lc-muted);
  transform: translateY(140%);
  transition: transform .18s var(--ds-ease-spring);
}
.ct-mouse-body::before, .ct-mouse-body::after { content: ''; position: absolute; top: -22%; width: 34%; aspect-ratio: 1; border-radius: 50%; background: inherit; }
.ct-mouse-body::before { left: -4%; }
.ct-mouse-body::after { right: -4%; }
.ct-mouse-field[data-phase="out"] .ct-mouse-body { transform: none; background: var(--lc-text); }
.ct-mouse-field[data-phase="clicked"] .ct-mouse-body { transform: translateY(40%); background: var(--lc-accent); }

.ct-math-task { margin: 0; text-align: center; font: 800 calc(var(--ds-fs-hero) * 1.1)/1.1 var(--lc-font); font-variant-numeric: tabular-nums; }
.ct-math-form { display: flex; gap: var(--ds-space-2); }
.ct-math-form .ct-btn { flex: none; min-height: var(--ds-touch); }
.ct-math-form.is-wrong { animation: ct-shake .32s ease; }
@keyframes ct-shake { 25% { transform: translateX(-5px); } 50% { transform: translateX(4px); } 75% { transform: translateX(-2px); } }
.ct-math-left { text-align: center; font-variant-numeric: tabular-nums; }

/* ── The full screen of a game ──────────────────────────────────────────────────────────────────── */
.ct-full {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  overflow: hidden;
  background: var(--lc-bg);
  color: var(--lc-text);

}
.ct-full[hidden] { display: none; }
.ct-full-head {
  display: flex;
  align-items: center;
  gap: var(--ds-space-2);
  min-height: 56px;
  padding: env(safe-area-inset-top, 0) var(--ds-space-3) 0 var(--ds-space-4);
}
.ct-full-title { flex: 1; min-width: 0; overflow-wrap: anywhere; font: 800 var(--ds-fs-display)/1.2 var(--lc-font); }
.ct-full-body {
  overflow-y: auto;
  min-height: 0;
  padding: var(--ds-space-2) var(--ds-space-4) calc(var(--ds-space-6) + env(safe-area-inset-bottom, 0));
}
.ct-full-body > .ct-game { width: min(100%, 34rem); margin-inline: auto; }
.ct-full-body .ct-game-head .ct-game-name, .ct-full-body .ct-game-head > .lc-icon { display: none; }
.ct-full-body :is(.ct-ttt, .ct-mines, .ct-sea) { max-width: min(100%, 30rem); }
.ct-full-body .ct-seas { grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr)); }
/* On a phone the seas are stacked. Leave room for the labels and controls without
   shrinking the cells indefinitely on a short screen (the body can scroll there). */
@media (max-width: 36rem) {
  .ct-full-body .ct-seas .ct-sea { max-width: min(100%, max(15rem, calc((100dvh - 12.5rem) / 2))); }
  .ct-full-body .ct-seas .ct-sea-box > span { text-align: center; }
}
.ct-full-body .ct-chess .ct-cell { font-size: min(calc(var(--ds-fs-hero) * 1.4), 9.5cqi); }
.ct-full-body .ct-card { width: 3rem; height: 4.25rem; }
html[data-ct-full="open"] body { overflow: hidden; }

/* ── The card above the message field ──────────────────────────────────────────────────────────── */
/* The card of a tool opens over the left side of the field, where the «+» that called it is. */
.ct-pop {
  position: absolute;
  right: auto;
  bottom: calc(100% + var(--ds-space-2));
  left: var(--composer-start, var(--ds-space-2));
  z-index: 6;
  display: grid;
  gap: var(--ds-space-2);
  box-sizing: border-box;
  width: 26rem;
  max-width: var(--composer-width, calc(100% - 2 * var(--ds-space-2)));
  max-height: min(70vh, 34rem);
  max-height: min(70vh, 34rem, var(--composer-room, 70vh));
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: var(--ds-space-3) var(--ds-space-4) var(--ds-space-4);
  background: color-mix(in srgb, var(--lc-card, var(--lc-bg)) 94%, transparent);
  background-image: none;
  transform-origin: 1.5rem 100%;

}
.ct-pop[hidden] { display: none; }
/* The head with the cross stays in sight while the card scrolls. */
.ct-pop-head { position: sticky; z-index: 1; top: calc(-1 * var(--ds-space-3)); margin-top: calc(-1 * var(--ds-space-3)); padding-inline: 0; background: var(--ds-surface-raised); }
.ct-pop-body { display: grid; gap: var(--ds-space-3); }
.ct-pop-note { margin: 0; color: var(--ds-red); font: 600 var(--ds-fs-label)/1.35 var(--lc-font); }
.ct-pop-note:empty:not(.hub-reader-only) { display: none; }
/* Two compact rows, no permanent help or heading. Keep real touch targets, not oversized panels. */
.ct-pop[data-compact-game] {
  width: 13.25rem;
  padding: var(--ds-space-2);
  background: var(--lc-card, var(--lc-bg));
}
.ct-game-setup { gap: var(--ds-space-2); min-width: 0; }
.ct-game-options { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: var(--ds-space-2); }
.ct-game-fields, .ct-game-actions { display: grid; gap: var(--ds-space-1); min-width: 0; }
.ct-game-actions--single { grid-auto-flow: column; }
.ct-setup-option, .ct-time-fields { display: flex; align-items: center; gap: var(--ds-space-1); min-width: 0; }
.ct-setup-option { gap: var(--ds-space-2); }
.ct-setup-option > .lc-icon { flex: none; width: var(--ds-icon-sm); height: var(--ds-icon-sm); color: var(--lc-muted); }
.ct-game-number {
  width: var(--ds-touch);
  padding-inline: var(--ds-space-1);
  text-align: center;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.ct-game-number[aria-invalid="true"] { box-shadow: inset 0 0 0 1px var(--ds-red); }
.ct-time-colon { color: var(--lc-muted); font-weight: 700; }
.ct-game-actions :is(.ct-icon-btn, .ct-send) { width: var(--ds-touch); height: var(--ds-touch); padding: 0; }
.ct-game-actions .ct-icon-btn::after { content: none; }
.ct-game-actions .ct-send .lc-icon { width: var(--ds-icon-sm); height: var(--ds-icon-sm); }
.ct-mine-setup { display: flex; flex-wrap: wrap; gap: var(--ds-space-2) var(--ds-space-3); }
select.ct-mine-size { width: 3.375rem; padding-inline: var(--ds-space-1); text-align-last: center; }
.ct-number-choices {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(var(--ds-touch), 1fr));
  gap: var(--ds-space-1);
  max-height: calc(2 * var(--ds-touch) + var(--ds-space-1));
  overflow-y: auto;
  overscroll-behavior: contain;
}
.ct-number-choices[hidden] { display: none; }
.ct-number-choices .ct-chip { min-height: var(--ds-touch); padding-inline: var(--ds-space-1); font-variant-numeric: tabular-nums; }
.ct-number-choices .ct-chip[aria-selected="true"] { background: var(--lc-button); color: var(--lc-on-button); }
.ct-dial { display: flex; align-items: center; justify-content: space-between; gap: var(--ds-space-2); }
.ct-step { width: var(--ds-touch); height: var(--ds-touch); background: var(--lc-control); color: var(--lc-text); }
.ct-step::after { content: none; }
.ct-timer-pick {
  flex: 1;
  text-align: center;
  font: 800 calc(var(--ds-fs-hero) * 1.6)/1 var(--lc-font);
  font-variant-numeric: tabular-nums;
  letter-spacing: -.02em;
}
.ct-timer-pick.is-tick { animation: ct-tick .22s var(--ds-ease-out); }
@keyframes ct-tick { from { transform: translateY(-4px); opacity: .55; } }
.ct-range { width: 100%; accent-color: var(--lc-button); }
.ct-chips { display: flex; flex-wrap: wrap; gap: var(--ds-space-1); }
.ct-chip {
  min-height: 34px;
  padding: 0 var(--ds-space-3);
  border: 0;
  border-radius: var(--ds-radius-pill);
  background: var(--lc-control);
  color: var(--lc-text);
  cursor: pointer;
  font: 700 var(--ds-fs-label)/1 var(--lc-font);
  transition: background-color var(--ds-dur-fast) ease, color var(--ds-dur-fast) ease;
}
.ct-chip[aria-pressed="true"] { background: var(--lc-button); color: var(--lc-on-button); }
.ct-pair-fields { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: var(--ds-space-2); }
.ct-result { min-height: 1.4em; font: 800 var(--ds-fs-display)/1.3 var(--lc-font); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.ct-quiz-edit { display: grid; gap: var(--ds-space-1); }
.ct-quiz-row { display: flex; align-items: center; gap: var(--ds-space-1); }
.ct-star {
  flex: none;
  width: var(--ds-touch);
  height: var(--ds-touch);
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--lc-muted);
  cursor: pointer;
  font: 400 var(--ds-fs-heading)/1 var(--lc-font);
}
.ct-star[aria-checked="true"] { color: var(--ds-amber); }

/* ── Templates in the «+» menu ──────────────────────────────────────────────────────────────────── */
.ct-templates { display: grid; gap: var(--ds-space-2); padding: var(--ds-space-1) var(--ds-space-1) var(--ds-space-2); }
.ct-tpl-list { display: grid; gap: 2px; max-height: 15rem; overflow-y: auto; }
.ct-tpl {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: start;
  gap: var(--ds-space-2);
  padding: var(--ds-space-2);
  border-radius: var(--ds-radius-lg);
  cursor: pointer;
}
.ct-tpl:hover { background: var(--lc-control); }
.ct-tpl + .ct-tpl { box-shadow: 0 -1px 0 var(--lc-hairline); }
.ct-check {
  flex: none;
  width: 18px;
  height: 18px;
  margin: 2px 0 0;
  padding: 0;
  border-radius: var(--ds-radius-sm);
  accent-color: var(--lc-button);
  cursor: pointer;
}
.ct-tpl-copy { display: grid; gap: 2px; min-width: 0; }
.ct-tpl-copy strong { overflow: hidden; font: 700 var(--ds-fs-body)/1.3 var(--lc-font); text-overflow: ellipsis; white-space: nowrap; }
.ct-tpl-copy .ct-muted { display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2; font-size: var(--ds-fs-label); line-height: 1.35; }
.ct-tpl-foot { display: flex; align-items: center; justify-content: space-between; gap: var(--ds-space-2); padding-top: var(--ds-space-1); }
.ct-tpl-foot .ct-send { flex: 1; width: auto; min-height: 38px; }
.ct-tpl-empty { display: grid; gap: var(--ds-space-2); padding: var(--ds-space-1) var(--ds-space-2) var(--ds-space-2); }

/* ── The hint above the message field: a quiet pill with the result, it slides in and out. ──────── */
/* The row of hints, centred above the field; a long row scrolls sideways without a bar. */
.ct-hints {
  position: absolute;
  bottom: calc(100% + var(--ds-space-1));
  left: calc(var(--composer-start) + var(--composer-width) / 2);
  z-index: 5;
  display: flex;
  gap: var(--ds-space-1);
  max-width: var(--composer-width);
  overflow-x: auto;
  scrollbar-width: none;
  border: 0;
  background: transparent;
  box-shadow: none;
  transform: translateX(-50%);

}
.ct-hints::after { content: ''; position: absolute; right: 0; bottom: -4px; left: 0; height: 8px; pointer-events: none; background: linear-gradient(to bottom, transparent, var(--lc-background)); filter: blur(3px); }
.ct-hints::-webkit-scrollbar { display: none; }
.ct-hints[hidden] { display: none; }
.ct-hint {
  display: inline-flex;
  flex: none;
  align-items: baseline;
  gap: var(--ds-space-2);
  min-height: 36px;
  padding: var(--ds-space-2) var(--ds-space-3);
  border: 0;
  border-radius: var(--ds-radius-pill);
  background: color-mix(in srgb, var(--lc-card, var(--lc-bg)) 96%, transparent);
  box-shadow: inset 0 1px 0 color-mix(in srgb, var(--lc-text) 8%, transparent);
  color: var(--lc-text);
  cursor: pointer;
  text-align: left;
  white-space: nowrap;
}
.ct-hint-expr { overflow: hidden; color: var(--lc-muted); font: 500 var(--ds-fs-body)/1.2 var(--lc-font); text-overflow: ellipsis; white-space: nowrap; }
.ct-hint-value { flex: none; font: 800 var(--ds-fs-control)/1.2 var(--lc-font); font-variant-numeric: tabular-nums; }

@media (prefers-reduced-motion: reduce) {
  .ct-skeleton, .ct-tool--timer[data-phase="running"] > .lc-icon, .ct-ttt .ct-cell[data-mark], .ct-random-value.is-landed,
  .ct-danger-last .ct-card, .ct-full, .ct-pop, .ct-hints, .ct-timer-pick.is-tick, .ct-math-form.is-wrong { animation: none; }
  .ct-mouse-body, .ct-flash, .ct-stone { transition: none; }
}
html[data-hub-motion="reduced"] :is(.ct-skeleton, .ct-tool--timer > .lc-icon, .ct-cell, .ct-card, .ct-full, .ct-pop, .ct-hint, .ct-timer-pick, .ct-math-form) { animation: none; }
@media (forced-colors: active) {
  .ct-cell, .ct-btn, .ct-chip, .ct-quiz-option { border: 1px solid ButtonText; }
}

/* ── Boards, second round (2026-11-14): where a piece may go, the last move, check; no gaps in the full screen. ── */
.ct-board8 .ct-cell[data-last="true"] { box-shadow: inset 0 0 0 99px color-mix(in srgb, var(--ds-amber) 42%, transparent); }
.ct-board8 .ct-cell[data-last="true"][data-picked="true"] { box-shadow: inset 0 0 0 99px color-mix(in srgb, var(--lc-button) 55%, transparent); }
.ct-board8 .ct-cell[data-check="true"] { background-image: radial-gradient(circle, color-mix(in srgb, var(--ds-red) 85%, transparent) 30%, color-mix(in srgb, var(--ds-red) 30%, transparent) 72%); }
.ct-board8 .ct-cell[data-target="move"]:not(:has(.ct-stone, .ct-piece))::before {
  content: '';
  position: absolute;
  inset: 36%;
  border-radius: 50%;
  background: rgb(20 20 24 / .42);
}
.ct-board8 .ct-cell[data-target="capture"],
.ct-board8 .ct-cell[data-target="move"]:has(.ct-stone, .ct-piece) {
  box-shadow: inset 0 0 0 3px var(--lc-button);
}
.ct-checkers .ct-cell[data-target="capture"]:not(:has(.ct-stone))::before {
  content: '';
  position: absolute;
  inset: 30%;
  border-radius: 50%;
  border: 3px solid var(--lc-button);
}
.ct-board8 .ct-cell[data-movable="true"] .ct-stone { box-shadow: 0 0 0 2px var(--lc-button), 0 1px 2px rgb(0 0 0 / .35); }
.ct-piece { position: relative; z-index: 1; line-height: 1; }

/* The card does not stretch its rows; the board keeps square cells with no gaps. */
.ct-game-body { align-content: start; }
.ct-grid { align-content: start; }

/* Same bounded width in every game state; the avatar column stays outside it. */
#chat-1x1-messages .chat-bubble > .chat-lc-bubble:has([data-live-kind="game"]) {
  box-sizing: border-box;
  width: min(94%, 22.75rem);
  max-width: 100%;
  min-width: 0;
  justify-content: stretch;
}
.ct-game .ct-tool-foot .ct-game-note { flex: 1; min-width: 0; }
.ct-icon-btn.ct-resign { color: var(--lc-muted); }
.ct-icon-btn.ct-resign:hover { background: color-mix(in srgb, var(--ds-red) 16%, transparent); color: var(--ds-red); }

/* ── Unfolded: the board in the middle of the screen, the status at the top, the note and the buttons at the
   bottom, within reach of the thumb. ── */
.ct-full-body { display: flex; flex-direction: column; }
.ct-full-body > .ct-game { display: flex; flex: 1 0 auto; flex-direction: column; gap: var(--ds-space-3); }
.ct-full-body .ct-game-head { display: flex; justify-content: center; }
.ct-full-body .ct-game-error { width: min(100%, 34rem); margin-inline: auto; box-sizing: border-box; }
.ct-full-body .ct-pill { padding: var(--ds-space-2) var(--ds-space-4); font-size: var(--ds-fs-control); }
.ct-full-body .ct-game-body { display: flex; flex: 1 0 auto; flex-direction: column; gap: var(--ds-space-3); }
.ct-full-body .ct-game-body > * { flex: none; }
.ct-full-body .ct-game-body > :first-child { margin-top: auto; }
.ct-full-body .ct-game-body > :last-child { margin-bottom: auto; }
.ct-full-body .ct-game-body > .ct-tool-foot:last-child { margin-top: auto; margin-bottom: 0; padding-top: var(--ds-space-3); }
.ct-full-body .ct-board-frame { max-width: min(100%, 32rem, calc(var(--app-height, 100dvh) - 15rem)); grid-template-columns: 1.25rem minmax(0, 1fr); grid-template-rows: auto 1.25rem; }
.ct-full-body :is(.ct-ranks, .ct-files) { font-size: var(--ds-fs-label); }
.ct-full-body .ct-tool-foot { gap: var(--ds-space-3); }
.ct-full-body .ct-game-note { font-size: var(--ds-fs-control); }
.ct-full-body .ct-btn.ct-resign { flex: none; min-height: var(--ds-touch); padding-inline: var(--ds-space-5); color: var(--ds-red); }

/* The maths race keeps its answer and button inside the card on any width. */
.ct-math-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--ds-space-2); }
.ct-math-form .ct-input { width: 100%; }
.ct-math-form .ct-btn { flex: none; min-width: 0; padding-inline: var(--ds-space-3); }

/* Durak: the trump card lies face up next to the number of cards left. */
.ct-trump { display: inline-flex; align-items: center; gap: var(--ds-space-2); }
.ct-trump-card { width: 2rem; height: 2.75rem; rotate: -90deg; margin-inline: .35rem; }
.ct-trump-card b { font-size: var(--ds-fs-label); }
.ct-trump-card i { font-size: var(--ds-fs-body); }
.ct-trump-suit { font: 400 var(--ds-fs-heading)/1 var(--lc-font); }
.ct-trump[data-red="true"] .ct-trump-suit { color: var(--ds-red); }
.ct-deck-mini { display: grid; place-items: center; min-width: 26px; height: 26px; padding: 0 4px; border-radius: var(--ds-radius-md); background: var(--lc-control); font: 800 var(--ds-fs-label)/1 var(--lc-font); }
.ct-durak-info { flex-wrap: wrap; }
