/* Tic-tac-toe. The board is a square sized by app.js (--side) to the room .board-wrap is given.
   Wide screens: the board with the two players and the turn line beside it.
   Upright screens: the players in a row on top, the board, then the turn line. */
.stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; gap: 26px;
  padding: 12px max(12px, var(--gk-safe-end)) max(12px, var(--gk-safe-bottom)) max(12px, var(--gk-safe-start)); }
.board-wrap { flex: 0 1 auto; min-width: 0; min-height: 0; height: 100%; max-height: 620px; aspect-ratio: 1; display: grid; place-items: center; }
.frame { --side: 320px; --pad: calc(var(--side) * .05); position: relative; width: var(--side); height: var(--side); padding: var(--pad); border-radius: calc(var(--side) * .075);
  background: linear-gradient(145deg, var(--gk-raise), var(--gk-rim)); border: 1px solid var(--gk-gold-deep); box-shadow: 0 0 0 3px var(--gk-rim), var(--gk-shadow-2), var(--gk-inset); }
/* The inlaid board: the gold showing between the dark squares is the inlay. */
.board { width: 100%; height: 100%; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-rows: repeat(3, minmax(0, 1fr)); gap: calc(var(--side) * .022); direction: ltr;
  border-radius: calc(var(--side) * .03); background: linear-gradient(145deg, var(--gk-gold-pale), var(--gk-gold-deep) 55%, var(--gk-gold-warm)); box-shadow: 0 0 0 calc(var(--side) * .01) var(--gk-gold-deep); }
.square { min-width: 0; min-height: 0; padding: 16%; display: grid; place-items: center; border: 0; border-radius: calc(var(--side) * .022); cursor: pointer;
  background: radial-gradient(circle at 35% 25%, var(--gk-raise), var(--gk-panel-deep) 70%); box-shadow: inset 0 calc(var(--side) * .012) calc(var(--side) * .02) var(--gk-dark), inset 0 -1px 0 var(--gk-line-soft); transition: filter var(--gk-fast); }
.square:not(:disabled):hover { filter: brightness(1.3); }
.square:disabled { cursor: default; opacity: 1; }
.square:focus-visible { outline: var(--gk-focus); outline-offset: calc(var(--side) * -.012); }
.square svg { width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.square.won { background: radial-gradient(circle at 35% 25%, color-mix(in srgb, currentColor 32%, var(--gk-raise)), var(--gk-panel-deep) 75%); }
.square.x { color: var(--mark-x); } .square.o { color: var(--mark-o); }
/* A new mark is drawn on: each stroke (pathLength 100, art.js) from start to end, the second stroke of an X after the first. */
/* At rest a mark is whole; the animation only adds the drawing-on, so a browser that skips it still shows the mark. */
.square.fresh .stroke path { stroke-dasharray: 100; animation: draw-on .26s ease-out both; }
.square.fresh .stroke.s1 path { animation-delay: .2s; }
@keyframes draw-on { from { stroke-dashoffset: 100; } to { stroke-dashoffset: 0; } }
.win-stroke { position: absolute; inset: var(--pad); width: calc(100% - 2 * var(--pad)); height: calc(100% - 2 * var(--pad)); pointer-events: none; display: none; color: var(--mark-x); }
.win-stroke.visible { display: block; }
.win-stroke.o { color: var(--mark-o); }
.win-stroke line { stroke: currentColor; stroke-width: 4; stroke-linecap: round; filter: drop-shadow(0 0 6px currentColor); stroke-dasharray: 430; animation: line-in .4s ease-out both; }
@keyframes line-in { from { stroke-dashoffset: 430; } to { stroke-dashoffset: 0; } }
/* A clear board behind New game and while a room waits for its people. */
html.gk-clear :is(.square svg, .win-stroke) { visibility: hidden; }

.side { flex: none; width: 288px; display: flex; flex-direction: column; gap: 16px; }
.seats { display: grid; gap: 8px; }
.seat-x { --seat: var(--mark-x); }
.seat-o { --seat: var(--mark-o); }
.gk-seat i { flex: none; width: 30px; height: 30px; color: var(--seat); }
/* On the player's face the mark is a small badge. */
.gk-seat i.gk-face-badge { padding: .17em; }
.gk-seat i svg { display: block; width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 8; stroke-linecap: round; }
.talk { min-height: 3.4em; padding-inline: 4px; }

/* Upright screens: players, board, turn line. */
@media (orientation: portrait) {
  .stage { flex-direction: column; gap: 12px; }
  .side { display: contents; }
  .seats { order: -1; width: min(100%, 560px); grid-template-columns: 1fr 1fr; }
  .board-wrap { flex: 0 1 auto; width: min(100%, 720px); height: auto; max-height: 100%; aspect-ratio: 1; }
  .talk { text-align: center; }
}
@media (max-width: 599px) {
  .gk-seat { padding: 7px 9px; gap: 8px; }
  .gk-seat i { width: 24px; height: 24px; }
}
@media (min-width: 600px) and (max-width: 1023px) {
  .stage { gap: 18px; padding-top: 18px; padding-bottom: max(22px, var(--gk-safe-bottom)); }
  .gk-turn { font-size: var(--gk-text-lg); }
}
/* A sideways phone. */
@media (orientation: landscape) and (max-height: 560px) {
  .stage { gap: 16px; padding-top: 6px; padding-bottom: max(6px, var(--gk-safe-bottom)); }
  .side { width: 250px; gap: 8px; }
  .gk-seat { padding: 6px 10px; }
  .talk { min-height: 0; }
}
@media (prefers-reduced-motion: reduce) { .square.fresh .stroke path { stroke-dashoffset: 0; animation: none; } .win-stroke line { animation: none; } .square { transition: none; } }
