/* TIC-TAC-TOE (Икс-Нол) — flat warm board, X terracotta / O slate-teal. Static states only, no motion. */
#view-tictactoe { --ttt-x:#a9432f; --ttt-o:#6f8a96; --ttt-x-soft:#f1dcd4; --ttt-o-soft:#dde6e9; }
html[data-theme="dark"] #view-tictactoe { --ttt-x:#d98a74; --ttt-o:#9fb7c2; --ttt-x-soft:#4a2f26; --ttt-o-soft:#2f3b3f; }
#view-tictactoe [hidden] { display:none !important; }

/* layout: board on the left, status / score / settings on the right; stacked on phones */
.ttt-layout {
  display:grid; gap:16px; align-items:start;
  grid-template-columns:minmax(0,1fr) minmax(260px,320px);
  grid-template-rows:auto auto auto 1fr;
  grid-template-areas:"play status" "play score" "play setup" "play .";
}
.ttt-statusbox { grid-area:status; }
.ttt-scorebox { grid-area:score; }
.ttt-setup { grid-area:setup; }
.ttt-play { grid-area:play; width:100%; max-width:clamp(280px, calc(100vh - 230px), 640px); margin:0 auto; min-width:0; }

.ttt-box { padding:16px; border-radius:18px; min-width:0; }
.ttt-h { margin:0 0 10px; font-size:11px; font-weight:800; letter-spacing:.12em; text-transform:uppercase; color:var(--ink-3); }

/* status */
.ttt-status { display:flex; align-items:center; gap:10px; margin:0; min-height:32px; font-size:clamp(18px,2.2vw,23px); font-weight:800; line-height:1.25; color:var(--ink); }
.ttt-status.is-good { color:var(--green-700); }
.ttt-status.is-bad { color:var(--danger); }
.ttt-status.is-draw, .ttt-status.is-wait { color:var(--ink-2); }
.ttt-status .ttt-mini, .ttt-status .ttt-emoji { width:1.35em; height:1.35em; font-size:1em; }
.ttt-tip { margin:8px 0 0; font-size:13.5px; font-weight:600; line-height:1.5; color:var(--ink-2); }
.ttt-meta { margin:8px 0 0; font-size:12px; font-weight:600; color:var(--ink-3); }
.ttt-meta b { color:var(--ink-2); font-weight:800; }

/* small marks used in status / score / settings */
.ttt-mini { flex:none; display:inline-grid; place-items:center; width:26px; height:26px; line-height:1; }
.ttt-mini .ttt-svg { width:100%; height:100%; display:block; }
.ttt-emoji { flex:none; display:inline-grid; place-items:center; font-size:20px; line-height:1; }
.ttt-x { color:var(--ttt-x); }
.ttt-o { color:var(--ttt-o); }

/* score tiles: X | Тэнцээ | O */
.ttt-score { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:8px; }
.ttt-tile { display:flex; flex-direction:column; align-items:center; gap:4px; min-width:0; padding:10px 6px 8px; border-radius:14px; border:2px solid transparent; background:var(--surface-2); text-align:center; }
.ttt-tile b { max-width:100%; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-size:12.5px; font-weight:800; color:var(--ink-2); }
.ttt-num { font-family:var(--display,inherit); font-size:clamp(28px,3.4vw,38px); font-weight:800; line-height:1; font-variant-numeric:tabular-nums; color:var(--ink); }
.ttt-tile small { min-height:15px; font-size:10.5px; font-weight:800; letter-spacing:.06em; text-transform:uppercase; color:var(--ink-3); }
.ttt-tile.is-turn { border-color:var(--accent); background:var(--accent-soft); }
.ttt-tile.is-turn small { color:var(--green-700); }
.ttt-tile-x.is-winner { border-color:var(--ttt-x); background:var(--ttt-x-soft); }
.ttt-tile-o.is-winner { border-color:var(--ttt-o); background:var(--ttt-o-soft); }
.ttt-tile-d.is-winner { border-color:var(--line-2); background:var(--surface); }
.ttt-tile-x.is-winner small { color:var(--ttt-x); }
.ttt-tile-o.is-winner small { color:var(--ttt-o); }

/* the board */
.ttt-board {
  container-type:inline-size;
  display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:clamp(6px,1.6vw,12px);
  aspect-ratio:1; padding:clamp(6px,1.6vw,12px);
  border-radius:clamp(16px,3vw,26px); border:1px solid var(--line-2);
  background:var(--surface-2); box-shadow:var(--shadow);
}
.ttt-cell {
  position:relative; display:grid; place-items:center; min-width:0; min-height:44px; aspect-ratio:1;
  margin:0; padding:0; border:2px solid var(--line); border-radius:clamp(10px,3cqi,20px);
  background:var(--surface); color:var(--ink); font:inherit; cursor:default;
  -webkit-tap-highlight-color:transparent;
}
.ttt-board.is-live .ttt-cell:not(.is-filled) { cursor:pointer; }
.ttt-board.is-live .ttt-cell:not(.is-filled):hover { border-color:var(--accent); }
.ttt-board.is-live .ttt-cell:not(.is-filled):active { background:var(--accent-soft); }
.ttt-cell:focus-visible { outline:3px solid var(--accent); outline-offset:-3px; }

.ttt-mark { display:block; width:68%; height:68%; pointer-events:none; }
.ttt-mark .ttt-svg { display:block; width:100%; height:100%; }
.ttt-ghost { position:absolute; inset:16%; width:auto; height:auto; opacity:0; }
@media (hover:hover) {
  .ttt-board.is-live .ttt-cell:not(.is-filled):hover .ttt-ghost { opacity:.2; }
}

/* keypad number in the corner of empty cells (keyboard hint) */
.ttt-key { position:absolute; top:7%; left:9%; font-size:max(11px,2.6cqi); font-weight:800; line-height:1; color:var(--ink-3); opacity:.7; pointer-events:none; }
.ttt-board.is-wait .ttt-key, .ttt-board.is-won .ttt-key, .ttt-board.is-draw .ttt-key { opacity:.35; }

/* last move: small dot so the computer's move is easy to spot */
.ttt-cell.ttt-last::after { content:""; position:absolute; right:9%; bottom:9%; width:max(8px,2cqi); height:max(8px,2cqi); border-radius:50%; background:var(--accent); }

/* winning three — static highlight, the rest fades back */
.ttt-cell.ttt-win-x { border-color:var(--ttt-x); background:var(--ttt-x-soft); }
.ttt-cell.ttt-win-o { border-color:var(--ttt-o); background:var(--ttt-o-soft); }
.ttt-board.is-won .ttt-cell:not(.ttt-win) .ttt-mark { opacity:.3; }
.ttt-board.is-wait { box-shadow:var(--shadow), inset 0 0 0 2px var(--line-2); }

/* actions + keyboard hint */
.ttt-actions { display:flex; flex-wrap:wrap; justify-content:center; gap:8px; margin-top:14px; }
.ttt-actions .btn { min-height:44px; }
.ttt-keys { margin:10px 0 0; text-align:center; font-size:12px; font-weight:600; color:var(--ink-3); }
.ttt-keys kbd { display:inline-block; min-width:20px; padding:1px 6px; border-radius:6px; border:1px solid var(--line-2); border-bottom-width:2px; background:var(--surface); color:var(--ink-2); font:inherit; font-weight:800; font-size:11px; text-align:center; }
@media (hover:none) { .ttt-keys, .ttt-key { display:none; } }

/* settings */
.ttt-field + .ttt-field { margin-top:12px; }
.ttt-label { display:block; margin-bottom:6px; font-size:12px; font-weight:800; color:var(--ink-3); }
.ttt-seg { display:grid; grid-auto-flow:column; grid-auto-columns:minmax(0,1fr); gap:4px; padding:4px; border-radius:14px; border:1px solid var(--line); background:var(--surface-2); }
.ttt-opt { display:inline-flex; align-items:center; justify-content:center; gap:6px; min-width:0; min-height:44px; padding:6px 10px; border:0; border-radius:10px; background:transparent; color:var(--ink-2); font:inherit; font-size:14px; font-weight:800; line-height:1.2; cursor:pointer; -webkit-tap-highlight-color:transparent; }
.ttt-opt:hover { background:var(--surface); color:var(--ink); }
.ttt-opt.is-on, .ttt-opt.is-on:hover { background:var(--accent); color:var(--accent-ink); box-shadow:var(--shadow); }
.ttt-opt .ttt-mini { width:20px; height:20px; }
.ttt-opt.is-on .ttt-mini { color:var(--accent-ink); }
.ttt-record { margin:12px 0 0; padding-top:12px; border-top:1px solid var(--line); font-size:12.5px; font-weight:600; line-height:1.5; color:var(--ink-3); }
.ttt-record b { color:var(--ink); font-weight:800; }

/* phones / narrow windows: status, score, board, settings */
@media (max-width:900px) {
  .ttt-layout { grid-template-columns:minmax(0,1fr); grid-template-rows:none; grid-template-areas:"status" "score" "play" "setup"; gap:12px; }
  .ttt-play { max-width:min(100%, 560px); }
}
@media (max-width:420px) {
  .ttt-box { padding:12px; border-radius:16px; }
  .ttt-opt { padding:6px; font-size:13px; gap:4px; }
  .ttt-tile { padding:8px 4px 6px; }
  .ttt-tile b { font-size:11.5px; }
  .ttt-actions .btn { flex:1 1 auto; }
}

/* large classroom displays */
@media (min-width:1500px) {
  .ttt-layout { grid-template-columns:minmax(0,1fr) 360px; }
  .ttt-play { max-width:clamp(280px, calc(100vh - 230px), 760px); }
}
