/* The page: the header with its menu, and how the board, status line, buttons and score cards are arranged. */

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--page-background);
  color: var(--text-color);
  font: 16px/1.45 var(--body-font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
/* dragging down on the board no longer pulls to refresh (which would lose the game on a phone) */
html, body { overscroll-behavior-y: contain; }

.page { max-width: 980px; margin: 0 auto; padding: 24px 16px 48px; }

/* ---- the header ---- */
.page-header {
  max-width: 928px;
  margin: 0 auto 28px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  align-items: center;
  justify-content: space-between;
}
.header-buttons { display: flex; align-items: center; gap: 16px; }   /* centered, so the ☰ lines up with the middle of New game */

/* the logo is a picture (art/logos/): the plain one, then one for each status (see achievements.css) */
.logo { margin: 0; display: flex; align-items: center; }

/* while no game is running, New game breathes a little to say "start here" */
@keyframes new-game-pulse { 50% { transform: scale(1.08); } }
.new-game-button.pulsing { animation: new-game-pulse 1.4s ease-in-out infinite; }

/* the ☰ sits flat on the page: still a real button for keyboards and screen readers, but with no box */
.button.menu-button { background: none; border: 0; border-radius: 6px; color: var(--muted-text-color); font-size: 30px; padding: 2px 6px; }
.button.menu-button:hover, .button.menu-button[aria-expanded="true"] { color: var(--text-color); }

/* the menu drops down from the ☰, right-aligned under it; each item opens a modal */
.menu-wrapper { position: relative; }
.menu {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 20; min-width: 250px; padding: 8px; display: grid; gap: 6px;
  border: 1px solid var(--line-color); border-radius: 12px; background: var(--panel-background);
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.55);
  transform-origin: top right; animation: menu-in 0.16s ease-out;
}
.menu[hidden] { display: none; }
@keyframes menu-in { from { opacity: 0; transform: scale(0.96) translateY(-4px); } }
/* each item is a rounded, off-white box with black text; it turns fully white when pointed at or focused */
.menu-item {
  text-align: left; padding: 13px 16px; border: 0; border-radius: 8px; background: #e2e2e4; color: #1d1d1f; cursor: pointer;
  font: 800 22px/1 var(--display-font); font-feature-settings: "case"; text-transform: uppercase; letter-spacing: 0.3px;
  transition: background-color 0.12s ease;
}
.menu-item:hover, .menu-item:focus-visible { background: #fff; outline: none; }
.menu-item[hidden] { display: none; }

/* ---- the play area: the board on the left, everything else on the right ---- */
.play-area {
  display: flex; flex-wrap: wrap; gap: 14px 28px; align-items: flex-start; justify-content: center;
  container-type: inline-size;
}
.board-wrapper { width: min(100%, var(--board-width)); }
.side-column { width: min(100%, 430px); display: flex; flex-direction: column; gap: 14px; }

/* One column, below 960px: the header sits close above the status line and the logo is as far from the top of the screen
   as from its left edge. On a tall screen the page fills the screen's height: the header at the top, the status line right
   under it, the score cards (and the last-move texts under them) at the bottom, and the board and buttons share the room in
   between evenly. On a screen too short for all of it nothing stretches and the page scrolls. */
@media (max-width: 959.9px) {
  .page-header { width: 100%; margin-bottom: 14px; }
  .page { min-height: 100dvh; display: flex; flex-direction: column; padding-top: 13px; padding-bottom: max(16px, env(safe-area-inset-bottom)); }
  .page > .play-area { flex: 1 0 auto; flex-direction: column; flex-wrap: nowrap; align-items: center; justify-content: flex-start; }
}

/* When the two columns no longer fit side by side (470 + 28 + 430 = 928px), everything goes into one column in a new order:
   the status line, the board, the move buttons, the score cards (their label tabs stick up 18px, hence the room above), then the
   last-move texts. The side column stops being a box of its own (display: contents) so its parts can sit around the board. */
@container (max-width: 927.9px) {
  .side-column { display: contents; }
  .status-line, .score-cards, .last-moves, .actions { width: min(100%, var(--board-width)); }
  .status-line { order: 1; margin-bottom: 0; }
  .board-wrapper { order: 2; margin-top: auto; }
  .actions { order: 3; margin-top: auto; margin-bottom: 18px; display: flex; align-items: center; justify-content: space-between; gap: 10px; text-align: left; }
  .actions .actions-label { margin-bottom: 0; }
  .action-buttons { justify-content: flex-end; }
  .score-cards { order: 4; margin-top: auto; }
  .last-moves { order: 5; }
}

/* confetti: a full-screen layer over the page (under the modals) that never takes a tap */
.confetti-canvas { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 40; }

@media (prefers-reduced-motion: reduce) {
  .menu { animation: none; }
  .new-game-button.pulsing { animation: none; }
}
