/* Minesweeper — own styles, theme tokens only. */

.ms {
  width: 100%;
  max-width: 640px;
}

.ms-bar {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.ms-stat {
  min-width: 84px;
  padding: 8px 14px 6px;
  text-align: center;
  border-radius: 10px;
  background: var(--gm-surface, #1b2740);
  border: 1px solid var(--gm-line, rgba(255, 255, 255, 0.09));
}

.ms-stat b {
  display: block;
  font: 500 1.35rem/1.15 var(--gm-display, "Fraunces", Georgia, serif);
  font-variant-numeric: tabular-nums;
}

.ms-lab {
  display: block;
  font-size: 0.64rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gm-muted, rgba(242, 238, 230, 0.66));
}

.ms-flagbtn {
  min-height: 44px;
  align-self: center;
  touch-action: manipulation;
}

.ms-flagbtn[aria-pressed="true"] {
  background: var(--gm-accent, #c0392b);
  border-color: var(--gm-accent, #c0392b);
  color: #fff;
}

.ms-board {
  --n: 9;
  container-type: inline-size;
  display: grid;
  grid-template-columns: repeat(var(--n), 1fr);
  gap: 2px;
  width: 100%;
  padding: 6px;
  box-sizing: border-box;
  background: var(--gm-surface, #1b2740);
  border: 1px solid var(--gm-line, rgba(255, 255, 255, 0.09));
  border-radius: var(--gm-radius, 12px);
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

.ms-cell {
  appearance: none;
  -webkit-appearance: none;
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 20%;
  cursor: pointer;
  touch-action: manipulation;
  font: 700 calc(100cqw / var(--n) * 0.55)/1 var(--gm-body, "DM Sans", system-ui, sans-serif);
  color: var(--gm-text, #f2eee6);
  background: var(--gm-sq-dark, #6b3a44);
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.28), inset 0 2px 0 rgba(255, 255, 255, 0.16);
  transition: background 0.15s ease;
}

.ms-cell:hover { background: var(--gm-accent, #8a4a56); }

.ms-cell:focus-visible {
  outline: 3px solid var(--gm-accent-bright, #e0584a);
  outline-offset: -2px;
  position: relative;
  z-index: 2;
}

.ms-cell.is-open {
  cursor: default;
  background: var(--gm-bg-2, #131c2b);
  box-shadow: inset 0 0 0 1px var(--gm-line, rgba(255, 255, 255, 0.09));
}

.ms-cell.is-open.is-num { cursor: pointer; }

.ms-cell svg {
  width: 62%;
  height: 62%;
  pointer-events: none;
}

.ms-cell.is-flag { color: var(--gm-accent-bright, #e0584a); }
.ms-cell.is-flag svg { color: var(--gm-flag, #ffd25a); }
.ms-cell.is-mine svg { color: var(--gm-text, #f2eee6); }
.ms-cell.is-hit { background: var(--gm-accent, #c0392b); }
.ms-cell.is-hit svg { color: #fff; }
.ms-cell.is-wrong { box-shadow: inset 0 0 0 2px var(--gm-accent-bright, #e0584a); }
.ms-cell.is-good { background: var(--gm-accent-soft, rgba(88, 190, 130, 0.35)); }

.ms-cell[data-n="1"] { color: var(--gm-n1, #4aa3ff); }
.ms-cell[data-n="2"] { color: var(--gm-n2, #4fcf7a); }
.ms-cell[data-n="3"] { color: var(--gm-n3, #ff6b5e); }
.ms-cell[data-n="4"] { color: var(--gm-n4, #b48cff); }
.ms-cell[data-n="5"] { color: var(--gm-n5, #ffb04a); }
.ms-cell[data-n="6"] { color: var(--gm-n6, #3fd0c9); }
.ms-cell[data-n="7"] { color: var(--gm-n7, #f2a6d0); }
.ms-cell[data-n="8"] { color: var(--gm-n8, #c9c9c9); }

#gm-minesweeper .gm-status { margin-top: 12px; }

@media (max-width: 480px) {
  .ms-bar { gap: 6px; }
  .ms-stat { min-width: 66px; padding: 8px 8px 6px; }
  .ms-board { padding: 4px; gap: 1px; }
  .ms-cell { font-size: calc(100cqw / var(--n) * 0.55); }
  .ms-flagbtn { padding: 10px 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .ms-cell { transition: none; }
}

#ms-level { border-radius: 16px; }
