/* Tìm số — trên nền shared/css/app.css (token, thẻ, nút, nav, hộp thoại) và shared/css/game.css (màn hình
   ván, hộp thoại kết quả và bảng xếp hạng của nó). Trang người chơi, luyện tập và các mục của trò trên trang
   Admin (form cài đặt và số liệu trực tiếp của bảng điều khiển nằm ở modules/admin/css/admin.css). */

/* --- Màn hình bảng số: mọi thứ trên một màn hình, bảng có cỡ để hiện trọn (js/board.js, fit) và
   chỉ cuộn khi các ô sẽ quá nhỏ để chạm --- */
.ts-play {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 10px;
  width: min(100%, 980px);
  min-height: 0;
  margin: 0 auto;
  padding: 10px var(--pad-right) calc(10px + var(--safe-bottom)) var(--pad-left);
}
.ts-target {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  border-radius: var(--radius);
  background: #241c17;
  color: #faf6f0;
}
.ts-target-label { display: block; color: #f2b45a; font-size: 13px; font-weight: 700; letter-spacing: 0.04em; }
.ts-target-number { display: block; font-family: "Playfair Display", Georgia, serif; font-size: clamp(40px, 12vw, 64px); font-variant-numeric: tabular-nums; line-height: 1; }
.ts-target-side { display: grid; justify-items: end; gap: 6px; }
.ts-timer { font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; }
.ts-timer.is-low { color: #ff9b8c; }
.ts-me { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; white-space: nowrap; }
.ts-dot { flex: none; width: 12px; height: 12px; border-radius: 50%; background: var(--c, #9c4728); box-shadow: 0 0 0 2px rgb(255 255 255 / 0.7); }

.ts-board-wrap { position: relative; flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.ts-board { display: grid; grid-template-columns: repeat(var(--cols, 10), minmax(0, 1fr)); gap: 4px; }
.ts-board-wrap .ts-board { max-width: 100%; margin: 0 auto; }
.ts-tile {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  min-width: 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  font-size: var(--tile-font, 16px);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition: background-color 0.15s, opacity 0.2s, transform 0.08s;
}
.ts-tile:active { transform: scale(0.94); }
.ts-tile.is-taken { border-color: transparent; background: var(--c); color: #fff; opacity: 0.32; cursor: default; }
.ts-tile.is-mine { opacity: 0.55; }
.ts-tile.is-pending { outline: 3px solid var(--c, var(--accent)); outline-offset: -3px; }
.ts-tile.is-wrong { border-color: var(--red); background: #fde4e1; color: var(--red); animation: ts-shake 0.35s; }
@keyframes ts-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-4px); }
  40% { transform: translateX(4px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(3px); }
}
@media (prefers-reduced-motion: reduce) {
  .ts-tile.is-wrong { animation: none; }
}
.ts-board.is-readonly .ts-tile { cursor: default; }
@media (hover: hover) {
  .ts-board:not(.is-readonly) .ts-tile:not(.is-taken):hover { border-color: var(--accent); }
}
/* Sau một lần chạm sai: bảng tối đi và một nhãn ở đỉnh bảng đếm ngược thời gian khoá. */
.ts-lock {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 12px;
  background: rgb(250 246 240 / 0.6);
}
.ts-lock span { padding: 10px 18px; border: 1px solid var(--red); border-radius: 999px; background: #fde4e1; color: var(--red); font-size: 17px; font-weight: 800; box-shadow: 0 10px 30px -12px rgb(43 35 30 / 0.4); }
.ts-countdown {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  background: rgb(36 28 23 / 0.78);
  color: #faf6f0;
  font-family: "Playfair Display", Georgia, serif;
  font-size: clamp(80px, 30vw, 200px);
  line-height: 1;
}
.ts-countdown.is-go { color: #f2b45a; font-size: clamp(48px, 14vw, 110px); }

.ts-leaders { display: flex; flex: none; gap: 8px; margin: 0; padding: 0 0 2px; overflow-x: auto; list-style: none; font-size: 14px; }
.ts-leaders li { display: inline-flex; flex: none; align-items: center; gap: 6px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--white); white-space: nowrap; }
.ts-leaders li.is-me { border-color: var(--accent); font-weight: 700; }
.ts-leaders b { font-variant-numeric: tabular-nums; }

/* --- Cài đặt luyện tập --- */
.ts-setup { display: grid; gap: 14px; width: min(100%, 560px); }
.ts-presets { margin: 0; padding: 0; border: 0; }
.ts-presets legend { margin-bottom: 8px; padding: 0; font-size: 14px; font-weight: 700; }
.ts-preset-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.ts-preset-grid label { position: relative; display: block; cursor: pointer; }
.ts-preset-grid input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: inherit; }
.ts-preset-grid span { display: block; padding: 10px 8px; border: 1px solid var(--line); border-radius: 12px; background: var(--white); font-weight: 800; text-align: center; }
.ts-preset-grid input:checked + span { border-color: var(--accent); background: var(--blush); }
.ts-preset-grid input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.ts-preset-grid input:disabled + span { opacity: 0.5; }
.ts-setup .segmented { margin: 0; }
.ts-best { color: var(--muted); font-size: 14px; }
.ts-best b { color: var(--ink); }
.key-wrong { border-color: var(--red); background: #fde4e1; color: var(--red); }

/* --- Admin: bảng số thu nhỏ của một ván --- */
.ts-board-mini { --tile-font: 11px; gap: 3px; }
.ts-board-mini .ts-tile { border-radius: 5px; cursor: default; }
.ts-board-mini .ts-tile.is-target { border-color: #241c17; box-shadow: 0 0 0 2px #f2b45a; }
.ts-overview { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
