/* Dots and Boxes. Functional layout before the design pass; existing tokens only. The board is drawn on the
   card's surface: dots and drawn lines in ink, undrawn lines as faint guides. Each player has a swatch
   (first vermilion, second cobalt) and a mark (their initial): a claimed box takes the swatch's light tone
   with the mark in its deep tone (D6: never color alone). The last line drawn is wider, in its player's
   swatch. All of it is listed for design review (docs/follow-ups.md). */

.g-dots { padding-block: var(--s3) var(--s7); }
.g-dots__intro { margin-bottom: var(--s3); }
.g-dots__intro h1 { font-size: 24px; }
.g-dots__intro p { margin-top: var(--s1); max-width: 60ch; }
.g-dots__note { margin-bottom: var(--s3); }

/* ---------- game card ---------- */
.g-dots__game { max-width: 560px; display: grid; gap: var(--s2); padding: var(--s3); }
@media (min-width: 400px) { .g-dots__game { padding: var(--s4); } }
.g-dots__game:focus { outline: none; }
.g-dots__bar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s4); }
.g-dots__bar-actions { margin-left: auto; display: flex; gap: var(--s2); }
.g-dots__bar-actions .btn { touch-action: manipulation; }

/* a player: their mark on their swatch, name and boxes; the one to move is underlined */
.g-dots__player { display: flex; align-items: center; gap: var(--s2); min-width: 0; padding-bottom: 4px; border-bottom: 3px solid transparent; }
.g-dots__player.is-turn { border-bottom-color: var(--field); }
.g-dots__chip {
  flex: none; display: grid; place-items: center; min-width: 32px; height: 32px; padding: 0 4px; border-radius: 6px;
  background: var(--light); color: var(--deep); font-weight: 800; font-size: 15px;
}
.g-dots__name { max-width: 9em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.g-dots__turn { display: flex; align-items: center; gap: var(--s2); min-height: 28px; font-weight: 600; }
.g-dots__turn-mark { flex: none; display: grid; }
.g-dots__turn-mark i { grid-area: 1 / 1; width: 18px; height: 18px; border-radius: 4px; background: var(--field); visibility: hidden; }
.g-dots__turn-mark.is-p1 i:first-child, .g-dots__turn-mark.is-p2 i:last-child { visibility: visible; }
.g-dots__hint { min-height: 1.4em; font-size: 15px; color: var(--ink-2); visibility: hidden; } /* keeps its space */
.g-dots__hint.is-shown { visibility: visible; }
.g-dots__foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s2) var(--s4); }
.g-dots__foot p { font-size: 15px; }

/* ---------- board ---------- */
.g-dots__stage { position: relative; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.g-dots__board { width: 100%; aspect-ratio: 1; border-radius: 12px; user-select: none; -webkit-user-select: none; cursor: pointer; }
.g-dots__board:focus { outline: none; }
.g-dots__board:focus-visible { box-shadow: 0 0 0 3px var(--ink); }
.g-dots__svg { display: block; width: 100%; height: 100%; overflow: visible; }

.g-dots__dot { fill: var(--ink); }
.g-dots__line { stroke: var(--line); stroke-width: 4; stroke-linecap: round; stroke-dasharray: 2 12; }
.g-dots__line.is-drawn { stroke: var(--ink); stroke-width: 8; stroke-dasharray: none; }
.g-dots__line.is-last { stroke: var(--field); stroke-width: 14; }
.g-dots__line.is-preview { stroke: var(--ink-2); stroke-width: 8; stroke-dasharray: none; opacity: .45; }
.g-dots__box rect { fill: transparent; }
.g-dots__box.is-claimed rect { fill: var(--light); }
.g-dots__box text { fill: var(--deep); font-family: var(--font); font-weight: 800; font-size: 44px; }
.g-dots__box text.is-long { font-size: 34px; }
.g-dots__cursor { fill: none; stroke: var(--ink); stroke-width: 5; display: none; pointer-events: none; }
.g-dots__board:focus-visible .g-dots__cursor { display: block; }

/* ---------- end panel, over the board ---------- */
.g-dots__panel { inset: 0; align-content: center; padding: var(--s5); }
.g-dots__panel[hidden] { display: none; }
.g-dots__over { justify-items: stretch; text-align: left; }
.g-dots__over .fig dd { font-size: 24px; }
.g-dots__over .fig dt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.g-dots__over .figs { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: var(--s3); }
.g-dots__over h2:focus { outline: none; }
.g-dots__over p { font-size: 15px; font-weight: 500; font-stretch: 100%; margin-top: var(--s3); }

/* ---------- new game dialog ---------- */
.g-dots__setup { display: grid; gap: var(--s4); }
.g-dots__field { display: grid; gap: var(--s2); justify-items: start; }
.g-dots__field[hidden], .g-dots__names[hidden] { display: none; }
.g-dots__setup .seg { flex-wrap: wrap; }
.g-dots__names { display: grid; gap: var(--s3); grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.g-dots__name-field { display: grid; gap: var(--s2); }
.g-dots__input {
  width: 100%; min-height: 48px; padding: 0 var(--s4);
  font-size: 18px; /* 16 px or more keeps iOS from zooming on focus */
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line-strong); border-radius: var(--r-pill);
}

.g-dots__dlg .fig dd { font-size: 22px; }
.g-dots__stats-pick { margin-bottom: var(--s3); flex-wrap: wrap; }
.g-dots__stats { grid-template-columns: repeat(3, minmax(0, 1fr)); margin: var(--s2) 0 var(--s3); }
.g-dots__reset { margin-top: var(--s4); }

/* ---------- play mode (docs/done-specs/20261011-game-play-mode.md): phones; /css/play-mode.css ---------- */
.g-dots__stage .play-start { border-radius: 12px; }
@media (max-width: 719px), (max-height: 599px) {
  .g-dots__game.is-play-mode { grid-template-rows: auto auto minmax(0, 1fr) auto; align-content: stretch; }
  /* the board as large as the space allows, square */
  .is-play-mode .g-dots__stage { container-type: size; min-height: 0; display: grid; place-items: center; }
  .is-play-mode .g-dots__board { width: min(100cqw, 100cqh); }
}
/* a phone held sideways: the board on the left at full height, the bar, turn and hint beside it */
@media (orientation: landscape) and (max-height: 599px) {
  .g-dots__game.is-play-mode { grid-template-columns: minmax(0, 1fr) minmax(200px, .7fr); grid-template-rows: auto auto minmax(0, 1fr); }
  .is-play-mode .g-dots__stage { grid-column: 1; grid-row: 1 / 4; }
  .is-play-mode .g-dots__bar { grid-column: 2; grid-row: 1; }
  .is-play-mode .g-dots__turn { grid-column: 2; grid-row: 2; }
  .is-play-mode .g-dots__hint { grid-column: 2; grid-row: 3; }
}

/* ---------- text below the game ---------- */
.g-dots__about { max-width: 62ch; margin-top: var(--s6); }
.g-dots__about h2 { margin: var(--s6) 0 var(--s3); }
.g-dots__about h2:first-child { margin-top: 0; }
.g-dots__about h3 { margin: var(--s5) 0 var(--s2); }
.g-dots__about p + p { margin-top: var(--s3); }
.g-dots__about ol { padding-left: 1.25em; margin: var(--s3) 0; }
.g-dots__about li + li { margin-top: 6px; }
.g-dots__keys { border-collapse: collapse; font-size: 15px; margin-bottom: var(--s3); }
.g-dots__keys th, .g-dots__keys td { text-align: left; padding: 6px var(--s4) 6px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.g-dots__keys th { font-weight: 600; }
