/* Tic-Tac-Go. Uses the site's tokens (styles.css); adds one color per player.
   X is the site's rust; O is the olive so the two read apart at a glance (different lightness), and the shapes differ too. */
.ttt [hidden] { display: none !important; }
.ttt { margin-top: 20px; --x: var(--rust); --o: var(--olive); --cell: var(--surface); --cell-line: var(--line); --bad: var(--danger); }

/* ---------- the board ---------- */
.ttt-board { --n: 3; display: grid; grid-template-columns: repeat(var(--n), 1fr); gap: 8px; width: 100%; aspect-ratio: 1; }
.ttt-cell { position: relative; padding: 0; border: 1px solid var(--cell-line); border-radius: 14px; background: var(--cell); color: var(--text); cursor: default; display: block; }
.ttt-cell:hover { filter: none; }
.ttt-cell svg { width: 100%; height: 100%; display: block; }
.ttt-cell .mark { display: none; }
.ttt-cell[data-p="X"] .mark-x, .ttt-cell[data-p="O"] .mark-o { display: inline; }
.ttt-cell .stroke { fill: none; stroke-width: 10; stroke-linecap: round; stroke-dasharray: 1; stroke-dashoffset: 0; }
.ttt-cell .mark-x .stroke { stroke: var(--x); }
.ttt-cell .mark-o .stroke { stroke: var(--o); }
.ttt-live .ttt-cell:not([data-p="X"]):not([data-p="O"]) { cursor: pointer; }
.ttt-live .ttt-cell:not([data-p="X"]):not([data-p="O"]):hover { border-color: var(--muted); }
.ttt-cell:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.ttt-cell.pending { border-color: var(--muted); }
.ttt-cell.win { border-color: currentColor; box-shadow: inset 0 0 0 2px currentColor; }
.ttt-cell.win[data-p="X"] { color: var(--x); }
.ttt-cell.win[data-p="O"] { color: var(--o); }
.ttt-cell.landed svg { animation: ttt-land .18s ease-out; }
.ttt-cell.nope { animation: ttt-shake .3s ease; }
.ttt-cell.contested { animation: ttt-shake .3s ease; box-shadow: inset 0 0 0 3px var(--bad); }
@keyframes ttt-land { from { transform: scale(1.18); } to { transform: none; } }
@keyframes ttt-shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

/* ---------- live game ---------- */
.ttt-play { max-width: 520px; margin: 0 auto; }
.ttt-players { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.ttt-player { display: grid; grid-template-columns: 34px 1fr; grid-template-rows: auto auto auto; column-gap: 8px; row-gap: 4px; align-items: center; }
.ttt-player[data-seat="O"] { grid-template-columns: 1fr 34px; text-align: right; }
.ttt-player[data-seat="O"] .ttt-glyph { grid-column: 2; grid-row: 1 / span 2; }
.ttt-player[data-seat="O"] .ttt-pname, .ttt-player[data-seat="O"] .ttt-pips { grid-column: 1; }
.ttt-player[data-seat="O"] .ttt-pips { justify-content: flex-end; }
.ttt-glyph { width: 34px; height: 34px; grid-row: 1 / span 2; fill: none; stroke-width: 12; stroke-linecap: round; }
.ttt-player[data-seat="X"] .ttt-glyph { stroke: var(--x); }
.ttt-player[data-seat="O"] .ttt-glyph { stroke: var(--o); }
.ttt-pname { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ttt-player.away .ttt-pname { color: var(--muted); }
.ttt-you { font-size: .75rem; font-weight: 600; color: var(--on-accent); background: var(--accent); border-radius: 6px; padding: 0 6px; vertical-align: 2px; }
.ttt-pips { display: flex; gap: 5px; }
.ttt-pips i { width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--line); }
.ttt-player[data-seat="X"] .ttt-pips i.on { background: var(--x); border-color: var(--x); }
.ttt-player[data-seat="O"] .ttt-pips i.on { background: var(--o); border-color: var(--o); }
/* Cooldown: full when you just moved, drains to empty when you can move again. */
.ttt-cool { grid-column: 1 / -1; height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.ttt-cool span { display: block; height: 100%; transform-origin: left; transform: scaleX(0); }
.ttt-player[data-seat="O"] .ttt-cool span { transform-origin: right; }
.ttt-player[data-seat="X"] .ttt-cool span { background: var(--x); }
.ttt-player[data-seat="O"] .ttt-cool span { background: var(--o); }
.ttt-cool.nope { animation: ttt-shake .3s ease; outline: 2px solid var(--bad); }

.ttt-stage { position: relative; }
.ttt-overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: clamp(4rem, 22vw, 9rem); font-weight: 800; letter-spacing: -.04em; color: var(--text); background: color-mix(in srgb, var(--bg) 40%, transparent); border-radius: 14px; pointer-events: none; }
.ttt-status { min-height: 1.6em; margin: 12px 0 6px; font-size: 1.1rem; font-weight: 600; text-align: center; }
.ttt-share, .ttt-after { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin: 12px 0; }
.ttt-share p { margin: 0 0 8px; }
.ttt-share input { flex: 1; min-width: 0; }
.ttt-btnrow { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.ttt-summary { margin-bottom: 12px; }
.ttt-summary td, .ttt-summary thead th:not(:first-child) { text-align: right; }
.ttt-quiet { background: none; color: var(--accent); }
.ttt-quiet.on { background: var(--accent); color: var(--on-accent); }
.ttt-keys { text-align: center; margin-top: 18px; }

/* ---------- lobby ---------- */
.ttt-hero { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(220px, 340px); gap: 36px; align-items: center; }
.ttt-hero h1 { font-size: clamp(2.4rem, 7vw, 3.6rem); letter-spacing: -.03em; line-height: 1; margin: 0 0 14px; }
.ttt-lede { font-size: 1.12rem; max-width: 56ch; margin: 0 0 12px; }
.ttt-rules { margin: 0 0 10px; padding-left: 20px; max-width: 60ch; }
.ttt-rules li { margin-bottom: 4px; }
.ttt-demo { margin: 0; }
.ttt-demo .ttt-board { gap: 6px; }
.ttt-demo .ttt-cell { border-radius: 10px; }
.ttt-demo figcaption { margin-top: 8px; }
@media (max-width: 720px) { .ttt-hero { grid-template-columns: 1fr; gap: 18px; } .ttt-demo { max-width: 220px; } }

.ttt-start h3, .ttt-stats h3 { margin: 0 0 6px; font-size: 1rem; }
.ttt-modes { display: flex; gap: 10px 22px; flex-wrap: wrap; margin-bottom: 14px; }
.ttt-mode { flex-direction: row; align-items: center; gap: 8px; color: var(--text); font-size: .95rem; cursor: pointer; }
.ttt-starts { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin-bottom: 12px; }
.ttt-start-box { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.ttt-start-box p { margin: 0 0 10px; }
#join-code { width: 8ch; text-transform: uppercase; letter-spacing: .12em; font-weight: 700; }
.ttt-open { margin-top: 18px; }
.ttt-open h3 .small { font-weight: 400; margin-left: 6px; }
.ttt-open-list { list-style: none; padding: 0; margin: 0; }
.ttt-open-list li { padding: 6px 0; border-bottom: 1px solid var(--line); }

.ttt-stat-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(200px, 280px); gap: 28px; align-items: start; margin-bottom: 22px; }
@media (max-width: 720px) { .ttt-stat-grid { grid-template-columns: 1fr; } }
.ttt-figures p { margin-top: 0; max-width: 62ch; }
.ttt-heat { margin: 0; }
.ttt-heat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; aspect-ratio: 1; }
.ttt-heat-cell { --heat: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; border-radius: 10px; border: 1px solid var(--cell-line);
  background: color-mix(in srgb, var(--accent) calc(var(--heat) * 70%), var(--cell)); font-variant-numeric: tabular-nums; }
.ttt-heat-cell strong { font-size: 1.15rem; }
.ttt-heat-cell span { font-size: .75rem; opacity: .8; }
.ttt-heat figcaption { margin-top: 8px; }
.ttt-won { font-weight: 700; }
.ttt-recent td, .ttt-leaders td { font-variant-numeric: tabular-nums; }

/* ---------- replay ---------- */
.ttt-replay { max-width: 520px; margin: 0 auto; }
.ttt-replay h1 { font-size: 1.6rem; margin: 0 0 4px; }
.ttt-controls { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.ttt-rounds { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
.ttt-rounds button { padding: 4px 9px; font-size: .85rem; }
.ttt-speed { flex-direction: row; align-items: center; gap: 6px; }
.ttt-speed select { font: inherit; padding: 4px 6px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--text); }
#scrub { width: 100%; accent-color: var(--accent); }

@media (prefers-reduced-motion: reduce) {
  .ttt-cell.landed svg, .ttt-cell.nope, .ttt-cell.contested, .ttt-cool.nope { animation: none; }
}
