/* Shared desktop play UI (chess, draughts, morpion). */

/* Keep the page at device width. A fixed canvas otherwise forces phones to zoom out. */
html, body {
  max-width: 100%;
  overflow-x: hidden;
}

.play-app {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 0.75rem 0 1.25rem;
}

.play-app .play-app__header,
.play-app .chess-app__header,
.play-app .draughts-app__header,
.play-app .chess-app__footer,
.play-app .draughts-app__footer,
.play-app .morpion-app__footer,
.play-app #game-meta,
.play-app #opponent-panel,
.play-app #player-panel {
  padding-left: 0.75rem;
  padding-right: 0.75rem;
  box-sizing: border-box;
  min-width: 0;
  max-width: 100%;
}

.play-app .chess-play-layout {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  gap: 0.75rem;
}

.play-app #board-section,
.play-app #board-stage {
  width: 100%;
  max-width: 100%;
  min-width: 0 !important;
  line-height: 0;
  overflow: hidden;
}

.play-app #chess-board,
.play-app #draughts-board {
  display: block;
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  height: auto !important;
  aspect-ratio: 1 / 1;
  border-radius: 0;
  border-left: none;
  border-right: none;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

.play-app .morpion-board {
  display: grid;
  width: 100%;
  max-width: 100%;
  aspect-ratio: 1 / 1;
  gap: 4px;
  padding: 4px;
  box-sizing: border-box;
  background: #0f172a;
  border: 1px solid #1e293b;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

.play-app .morpion-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 0.35rem;
  background: #f8fafc;
  color: #0f172a;
  font-size: clamp(1.75rem, 12vw, 4.5rem);
  font-weight: 800;
  line-height: 1;
  cursor: default;
}

.play-app .morpion-cell--x { color: #1d4ed8; }
.play-app .morpion-cell--o { color: #b91c1c; }

.play-app .morpion-cell--legal:not(:disabled) {
  background: #dbeafe;
  cursor: pointer;
  box-shadow: inset 0 0 0 2px #60a5fa;
}

.play-app .morpion-cell--last {
  box-shadow: inset 0 0 0 3px #f59e0b;
}

.play-app .morpion-cell:disabled {
  cursor: default;
}

.play-app .chess-players-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  padding: 0 0.75rem;
  box-sizing: border-box;
}

.play-app .chess-players-row #opponent-panel,
.play-app .chess-players-row #player-panel {
  padding-left: 0;
  padding-right: 0;
}

.play-app .chess-panel__moves {
  display: flex;
  flex-direction: column;
  min-height: 0;
  width: 100%;
}

.play-app .chess-panel__moves-list {
  margin: 0.5rem 0 0;
  padding: 0;
  list-style: none;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  max-height: 10rem;
  text-align: left;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.75rem;
  line-height: 1.4;
}

.play-app .chess-panel__moves-list li + li {
  margin-top: 0.25rem;
}

.play-app .chess-app__footer,
.play-app .draughts-app__footer,
.play-app .morpion-app__footer {
  overflow-wrap: anywhere;
  word-break: break-word;
}

@media (min-width: 900px) {
  .play-app {
    --play-board-size: min(512px, calc(100vh - var(--site-header-height, 3.5rem) - 10.5rem));
    max-width: 64rem;
    margin-left: auto;
    margin-right: auto;
    gap: 0.65rem;
    padding: 0.65rem 1rem 0.4rem;
    max-height: calc(100vh - var(--site-header-height, 3.5rem));
    overflow: hidden;
    box-sizing: border-box;
  }

  .play-app .chess-play-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) var(--play-board-size) minmax(0, 1fr);
    grid-template-areas:
      "opponent board player"
      ". meta .";
    gap: 0.75rem;
    align-items: start;
  }

  .play-app #board-section { grid-area: board; }
  .play-app #game-meta { grid-area: meta; padding-top: 0; padding-bottom: 0; }

  .play-app .chess-players-row {
    display: contents;
    padding: 0;
  }

  .play-app #opponent-panel,
  .play-app #player-panel {
    height: var(--play-board-size);
    max-height: var(--play-board-size);
    overflow: hidden;
    padding-left: 0;
    padding-right: 0;
  }

  .play-app #opponent-panel { grid-area: opponent; }
  .play-app #player-panel { grid-area: player; }

  .play-app #chess-board,
  .play-app #draughts-board,
  .play-app .morpion-board {
    width: var(--play-board-size) !important;
    max-width: var(--play-board-size) !important;
    height: var(--play-board-size) !important;
    border-radius: 0.25rem;
    border: 1px solid #1e293b;
  }

  .play-app .play-app__header {
    gap: 0.5rem;
  }

  .play-app .play-app__header h1 {
    font-size: 1.25rem;
    line-height: 1.2;
  }

  .play-app .room-code-copy {
    padding: 0.35rem 0.65rem;
  }

  .play-app .chess-app__footer,
  .play-app .draughts-app__footer,
  .play-app .morpion-app__footer {
    margin: 0;
    line-height: 1.2;
  }

  .play-app .chess-panel__moves {
    flex: 1 1 auto;
  }

  .play-app .chess-panel__moves-list {
    flex: 1 1 auto;
    max-height: none;
    min-height: 0;
  }
}
