/* Minesweeper. The board is a grid of equal squares; app.js sizes them (--cell) to the room .board-wrap is given.
   Upright screens, and the wide board on any screen: the counters and tools in a row above the board.
   Desktop with a square board: the counters on one side, the tools on the other, the board in the middle.
   A sideways phone: counters and tools in one column beside the board. */
.stage { flex: 1; min-height: 0; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 10px max(12px, var(--gk-safe-end)) max(12px, var(--gk-safe-bottom)) max(12px, var(--gk-safe-start)); }
.hud { flex: none; display: flex; align-items: center; justify-content: center; gap: 12px; }
.stats, .tools { display: flex; align-items: center; gap: 10px; }
.hud .gk-stat { min-width: 70px; padding: 4px 12px; }
.smiley { width: 50px; min-height: 50px; padding: 0; border-radius: 50%; font-size: 26px; line-height: 1; }
.board-wrap { flex: 1; min-height: 0; width: 100%; display: grid; place-items: center; }
/* The look of the squares is the player's board skin: app.js sets the --ms-… colours and shadows on the board from art.js
   (BOARD_STYLES). Where one is not set, the site's own navy and gold below are used (the classic board). */
.board {
  --cell: 30px; --bevel: calc(var(--cell) * .07); display: grid; grid-template-columns: repeat(var(--cols, 9), var(--cell)); grid-auto-rows: var(--cell); gap: 0;
  padding: calc(var(--cell) * .3); border-radius: calc(var(--cell) * .45); direction: ltr; user-select: none; -webkit-user-select: none; touch-action: manipulation;
  background: var(--ms-frame, linear-gradient(145deg, var(--gk-raise), var(--gk-rim))); border: 1px solid var(--ms-frame-edge, var(--gk-gold-deep));
  box-shadow: var(--ms-frame-shadow, 0 0 0 3px var(--gk-rim), var(--gk-shadow-2), var(--gk-inset));
}
/* A closed square is a bevelled key (classic: silver-blue, a bright top and start edge, a shaded bottom and end edge);
   a board skin may colour every other square differently (data-alt). An opened one is a well pressed into the board;
   its number takes its colour from art.js (--n1 … --n8). */
.cell {
  position: relative; margin: calc(var(--cell) * .035); padding: 0; border: 0; border-radius: var(--ms-round, 18%); font: var(--gk-number) calc(var(--cell) * .56)/1 var(--gk-font);
  background: var(--ms-cover); box-shadow: var(--ms-cover-shadow);
  color: var(--gk-on-gold); display: grid; place-items: center; overflow: hidden; -webkit-touch-callout: none;
}
.cell[data-alt] { background: var(--ms-cover-alt, var(--ms-cover)); box-shadow: var(--ms-cover-alt-shadow, var(--ms-cover-shadow)); }
.cell svg { width: 74%; height: 74%; pointer-events: none; }
.cell:hover:not(.open) { filter: brightness(1.07); }
.cell:active:not(.open):not(.flag) { box-shadow: var(--ms-press); }
.cell.open { background: var(--ms-open, var(--gk-rim)); box-shadow: var(--ms-sunk, var(--gk-sunk)); cursor: default; animation: open .16s ease-out; }
.cell.open.number { cursor: pointer; text-shadow: var(--ms-ink-shadow); }
@keyframes open { from { background: var(--ms-open-from); scale: .9; } }
.cell.n1 { color: var(--n1); } .cell.n2 { color: var(--n2); } .cell.n3 { color: var(--n3); } .cell.n4 { color: var(--n4); }
.cell.n5 { color: var(--n5); } .cell.n6 { color: var(--n6); } .cell.n7 { color: var(--n7); } .cell.n8 { color: var(--n8); }
.cell.flag svg { animation: plant .22s cubic-bezier(.2, 1.5, .4, 1); }
@keyframes plant { from { scale: 1.35; translate: 0 -12%; } }
/* After a loss the hidden mines show in pale wells; the one that went off is red; a wrong flag is crossed out. */
.cell.mine { background: var(--ms-well, color-mix(in srgb, var(--gk-ink-soft) 55%, var(--gk-rim))); box-shadow: var(--ms-sunk, var(--gk-sunk)); }
.cell.hit { background: var(--ms-hit, radial-gradient(circle, var(--gk-gold-pale), var(--gk-leave) 62%)); animation: boom .4s ease-out; }
@keyframes boom { 0% { scale: 1.5; } 100% { scale: 1; } }
.cell.wrong { background: var(--ms-wrong); }
.cell.wrong::after { content: ""; position: absolute; inset: 18%; background: linear-gradient(45deg, transparent 44%, var(--ms-cross) 44% 56%, transparent 56%), linear-gradient(-45deg, transparent 44%, var(--ms-cross) 44% 56%, transparent 56%); }
.board.won .cell.flag svg { animation: cheer .5s ease-out backwards; }
@media (prefers-reduced-motion: reduce) { .cell.open, .cell.flag svg, .cell.hit, .board.won .cell.flag svg { animation: none; } }
@keyframes cheer { 50% { scale: 1.25; } }

/* A phone: no room for the best time or the flag button's words. */
@media (max-width: 599px) { .hud { gap: 8px; } .stats, .tools { gap: 8px; } .best-stat, #flag-mode span + span { display: none; } .hud .gk-stat { min-width: 62px; padding: 4px 8px; } }
/* A tablet: a larger row above the board. */
@media (min-width: 600px) and (max-width: 1023px) { .stage { gap: 14px; padding-top: 14px; } .hud { gap: 16px; } .hud .gk-stat { min-width: 92px; } }
/* Desktop, a square board: the board takes the height, with a column on each side of it. */
@media (min-width: 1024px) {
  .stage:not([data-shape=wide]) { flex-direction: row; justify-content: center; gap: 22px; padding-top: 14px; }
  .stage:not([data-shape=wide]) .hud { display: contents; }
  .stage:not([data-shape=wide]) :is(.stats, .tools) { flex: none; width: 148px; flex-direction: column; align-items: stretch; gap: 12px; }
  .stage:not([data-shape=wide]) .stats { order: 1; } .stage:not([data-shape=wide]) .tools { order: 3; align-items: center; }
  .stage:not([data-shape=wide]) .board-wrap { order: 2; flex: 0 1 auto; width: auto; height: 100%; aspect-ratio: calc(var(--cols, 9) + .7) / calc(var(--rows, 9) + .7); max-height: calc((var(--rows, 9) + .6) * var(--cell-max) + 8px); }
  .stage:not([data-shape=wide]) .tools .gk-btn:not(.smiley) { width: 100%; }
  .stage:not([data-shape=wide]) .smiley { width: 64px; min-height: 64px; font-size: 32px; }
  .stage[data-shape=wide] .hud { gap: 16px; } .stage[data-shape=wide] .gk-stat { min-width: 92px; }
}
/* A sideways phone. */
@media (orientation: landscape) and (max-height: 560px) {
  .stage, .stage:not([data-shape=wide]) { display: grid; grid-template-columns: 124px minmax(0, 1fr); gap: 6px 10px; padding-top: 6px; padding-bottom: max(6px, var(--gk-safe-bottom)); }
  .hud, .stage:not([data-shape=wide]) .hud { display: flex; flex-direction: column; gap: 8px; }
  .stats, .tools, .stage:not([data-shape=wide]) :is(.stats, .tools) { width: auto; flex-direction: column; align-items: stretch; gap: 8px; } .tools { align-items: center; }
  .board-wrap, .stage:not([data-shape=wide]) .board-wrap { width: 100%; height: 100%; aspect-ratio: auto; max-height: none; }
  .best-stat, #flag-mode span + span { display: none; }
}
