/* Tic Tac Toe — scoped under .ttt */
.ttt {
  --x: var(--red);
  --o: var(--blue);
  --grid: var(--line);
  display: grid; gap: 14px;
  width: 100%; max-width: 460px; margin-inline: auto;
}
.ttt .ttt-wide { width: 100%; }
.ttt .ttt-wide button { flex: 1 1 0; min-width: 0; padding-left: 6px; padding-right: 6px; }
.ttt .ttt-quiet { animation: none; }
.ttt .ttt-note { font-size: var(--t-sm); color: var(--muted); }

.ttt-score { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: stretch; }
.ttt-side {
  display: flex; align-items: center; gap: 8px;
  min-height: 48px; padding: 6px 12px;
  border-radius: var(--pill); background: var(--surface-2);
  border: 2px solid transparent;
  font-size: var(--t-sm); font-weight: 620; color: var(--ink-2);
  transition: border-color .2s, background .2s;
}
.ttt-side[data-side="b"] { justify-content: flex-end; }
.ttt-side b { font-size: var(--t-lg); color: var(--ink); font-variant-numeric: tabular-nums; }
.ttt-side[data-side="a"] b { margin-left: auto; }
.ttt-side[data-side="b"] b { margin-right: auto; }
.ttt-side.is-turn { border-color: var(--ink); background: var(--surface); }
.ttt-draws { flex-direction: column; justify-content: center; gap: 0; padding: 4px 12px; border-radius: var(--r-md); font-size: 12px; }
.ttt-draws b { font-size: var(--t-md, 17px); }
.ttt-mk { width: 22px; height: 22px; flex: none; }
.ttt-mk svg { width: 100%; height: 100%; display: block; }

.ttt-wrap { position: relative; }
.ttt-board {
  position: relative;
  display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr);
  width: 100%; max-width: max(270px, calc(100svh - 300px));
  margin-inline: auto; aspect-ratio: 1;
  padding: 10px; gap: 10px;
  border-radius: var(--r-lg); background: var(--surface-2);
  touch-action: none; user-select: none; -webkit-user-select: none;
}
.ttt-cell {
  position: relative; display: grid; place-items: center;
  border: 0; border-radius: var(--r-md); background: var(--surface);
  box-shadow: 0 1px 0 var(--line);
  cursor: pointer; padding: 0; color: inherit;
  transition: background .15s, transform .12s;
}
.ttt-cell:not(:disabled):hover { background: color-mix(in srgb, var(--surface) 88%, var(--ink)); }
.ttt-cell:not(:disabled):active { transform: scale(.97); }
.ttt-cell:disabled { cursor: default; }
.ttt-cell:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.ttt-board.is-wait .ttt-cell { cursor: wait; }
.ttt-cell svg { width: 74%; height: 74%; overflow: visible; }
.ttt-x, .ttt-o { fill: none; stroke-width: 13; stroke-linecap: round; }
.ttt-x { stroke: var(--x); stroke-dasharray: 150; stroke-dashoffset: 0; animation: ttt-draw .28s ease-out; }
.ttt-o { stroke: var(--o); stroke-dasharray: 170; stroke-dashoffset: 0; animation: ttt-draw .3s ease-out; transform: rotate(-90deg); transform-origin: 50% 50%; }
.ttt-mk .ttt-x, .ttt-mk .ttt-o { animation: none; stroke-width: 15; }
@keyframes ttt-draw { from { stroke-dashoffset: 170; } }
.ttt-cell.is-win { background: color-mix(in srgb, var(--surface) 80%, var(--yellow)); }

.ttt-line { position: absolute; inset: 10px; width: calc(100% - 20px); height: calc(100% - 20px); pointer-events: none; overflow: visible; }
.ttt-line line { stroke: var(--ink); stroke-width: 9; stroke-linecap: round; stroke-dasharray: 420; stroke-dashoffset: 420; opacity: 0; }
.ttt-line.is-on line { opacity: .85; stroke-dashoffset: 0; transition: stroke-dashoffset .4s ease-out .1s; }

.ttt-status { text-align: center; font-weight: 640; min-height: 1.4em; }
.ttt-actions { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }
.ttt-actions button:disabled { opacity: .45; }

@media (max-width: 359px) {
  .ttt-side { padding: 6px 8px; gap: 5px; font-size: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .ttt-x, .ttt-o { animation: none; }
  .ttt-line.is-on line { transition: none; }
}
