/*
 * Play vs computer (computer-opponent mission WP09, T051): the setup screen
 * (src/ui/play-setup.js) and the play view (app.js 'play vs computer',
 * src/ui/play-controls.js, src/ui/play-result.js). Tokens and primitives
 * only (tokens.css, base.css); the board and the status line keep their own
 * styles (board.css).
 *
 *   .play-setup          a .panel: heading, the ladder, the colour, Start
 *   .play-choice         one radio with its label (and the level's one-line
 *                        description); the whole row is a 44 px target
 *   .play                the play view; grid areas
 *     >= 720 px          heading over  board | side (result, moves played)
 *     < 720 px           one column: heading, board with status and
 *                        controls, result, moves played
 *   .play-controls       Take back, Resign, New game; the in-page questions
 *   .play-result         the result panel (accent edge, never colour alone:
 *                        the heading says the outcome)
 * No horizontal scroll from 360 px: every track can shrink to 0.
 */

/* ---- setup ------------------------------------------------------------------ */

.play-setup {
  max-width: 44rem;
  margin: 0 auto;
  gap: var(--space-4);
  padding: var(--space-5);
}

.play-setup__title {
  font-size: var(--text-page-title);
  line-height: var(--line-height-tight);
}

.play-setup__form fieldset {
  display: grid;
  gap: var(--space-2);
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.play-setup__form legend {
  margin-bottom: var(--space-2);
  padding: 0;
  font-size: var(--text-panel-title);
  font-weight: var(--font-weight-semibold);
}

.play-setup__level-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-2);
}

.play-choice {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  column-gap: var(--space-2);
  min-height: var(--touch-target);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-md);
  background: var(--surface-raised);
}

.play-choice:has(input:checked) {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.play-choice input {
  width: 1.25rem;
  height: 1.25rem;
  margin: 0;
  accent-color: var(--accent);
}

/* WebKit can change the focused radio without applying :focus-visible to it. */
.play-choice input:focus {
  outline: var(--focus-ring-width) solid var(--color-focus);
  outline-offset: var(--focus-ring-offset);
}

.play-choice__label {
  font-weight: var(--font-weight-semibold);
  cursor: pointer;
}

.play-choice__description {
  grid-column: 2;
  color: var(--color-text-muted);
}

.play-setup__actions button {
  min-height: var(--touch-target);
}

/* ---- play view ----------------------------------------------------------------- */

.play {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas:
    "heading"
    "board"
    "side";
  gap: var(--space-3);
  align-items: start;
}

.play__heading {
  grid-area: heading;
  min-width: 0;
}

.play__title {
  font-size: var(--text-section-title);
  line-height: var(--line-height-tight);
}

.play__players {
  margin: var(--space-1) 0 0;
  color: var(--color-text-muted);
  overflow-wrap: anywhere;
}

.play__board {
  grid-area: board;
  display: grid;
  justify-items: center;
  gap: var(--space-3);
  min-width: 0;
}

.play__board > monolith-play-status,
.play__board > .play-controls {
  width: min(100%, 560px);
}

.play__side {
  grid-area: side;
  min-width: 0;
  overflow-wrap: anywhere;
}

.play__moves {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-3);
  margin: 0;
  padding: 0;
  list-style: none;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
}

.play button {
  min-height: var(--touch-target);
}

.play-controls__buttons,
.play-controls__confirm {
  justify-content: center;
}

.play-controls__confirm {
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-warning-surface);
}

.play-controls__question {
  margin: 0;
  font-weight: var(--font-weight-semibold);
}

.play-result {
  border-left: 4px solid var(--accent);
}

.play-result__title {
  font-size: var(--text-page-title);
  line-height: var(--line-height-tight);
}

.play-result__players,
.play-result__points {
  margin: 0;
}

@media (min-width: 720px) {
  .play {
    grid-template-columns: minmax(0, 560px) minmax(16rem, var(--side-panel-width));
    grid-template-areas:
      "heading heading"
      "board   side";
    justify-content: center;
    gap: var(--space-4);
  }
}

@media (max-width: 599.98px) {
  .play-setup {
    padding: var(--space-4);
  }

  .play-setup__level-list {
    grid-template-columns: minmax(0, 1fr);
  }
}
