:root {
  --ms-bg: #c0c0c0;
  --ms-dark: #808080;
  --ms-light: #ffffff;
  --ms-mid: #dfdfdf;
  --ms-black: #000000;
}

/* 经典 Windows 扫雷味道 */
body {
  margin: 0;
  background: #0b1220;
}

.msPage .wrap {
  /* 让游戏区域铺满整屏 */
  min-height: 100dvh;
  padding: 0;
  place-items: stretch;
}

.msPage .card.msCard {
  width: 100%;
  height: 100dvh;
  max-width: none;
  border-radius: 0;
  padding: 14px 14px;
  display: flex;
  flex-direction: column;
  box-shadow: none;
  border: none;
  overflow: hidden;
}

.msCard {
  width: min(720px, 100%);
}

.msCard .header {
  display: grid;
  gap: 10px;
}

.msHeadRow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

/* 游戏区域竖着（居中一列），按键区域保持横向左右布局 */
.msFrame {
  width: fit-content;
  margin-left: auto;
  margin-right: auto;
}

.msBoardWrap {
  margin-top: 10px;
  margin-left: auto;
  margin-right: auto;
}

/* 保持横向：左边难度，右边提示/说明 */
.msDiff {
  justify-content: flex-start;
}
.msOps {
  justify-content: flex-end;
}

.msHeadRow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.msFrame {
  margin-top: 10px;
  background: var(--ms-bg);
  padding: 12px;
  border-radius: 14px;
  /* 外框凸起效果 */
  box-shadow:
    inset 2px 2px 0 var(--ms-light),
    inset -2px -2px 0 var(--ms-dark);
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  /* 中级/高级如果棋盘太大：只允许向下滚动（往下延伸），不做横向滚动 */
  overflow-y: auto;
  overflow-x: hidden;
}

.msTopBar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  padding: 8px;
  background: var(--ms-bg);
  border-radius: 10px;
  box-shadow:
    inset 2px 2px 0 var(--ms-light),
    inset -2px -2px 0 var(--ms-dark);
}

.msCounter {
  justify-self: start;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-weight: 1200;
  letter-spacing: 1px;
  font-size: 22px;
  padding: 6px 10px;
  border-radius: 8px;
  color: #ff2d2d;
  background: #000;
  box-shadow:
    inset 2px 2px 0 rgba(255, 255, 255, 0.12),
    inset -2px -2px 0 rgba(0, 0, 0, 0.55);
}
#timeCounter {
  justify-self: end;
}

.msFace {
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  background: var(--ms-bg);
  font-size: 22px;
  box-shadow:
    inset 2px 2px 0 var(--ms-light),
    inset -2px -2px 0 var(--ms-dark);
}
.msFace:active {
  box-shadow:
    inset -2px -2px 0 var(--ms-light),
    inset 2px 2px 0 var(--ms-dark);
}

.msBoardWrap {
  margin-top: 10px;
  padding: 10px;
  background: var(--ms-bg);
  border-radius: 10px;
  box-shadow:
    inset 2px 2px 0 var(--ms-light),
    inset -2px -2px 0 var(--ms-dark);
  width: fit-content;
  margin-left: auto;
  margin-right: auto;
}

.msBoard {
  --cell: 26px; /* 会被 JS 动态覆盖，以适配全屏 */
  display: grid;
  grid-template-columns: repeat(var(--cols), var(--cell));
  grid-auto-rows: var(--cell);
  gap: 0;
  user-select: none;
  /* 手机端：我们自己处理“轻触翻开 / 长按插旗”，避免被页面滚动/缩放手势抢走 */
  touch-action: none;
  background: var(--ms-dark);
  padding: 1px;
}

.msCell {
  width: var(--cell);
  height: var(--cell);
  display: grid;
  place-items: center;
  font-weight: 1200;
  font-size: 16px;
  color: #111827;
  background: var(--ms-bg);
  cursor: pointer;
  /* 未翻开：凸起 */
  box-shadow:
    inset 2px 2px 0 var(--ms-light),
    inset -2px -2px 0 var(--ms-dark);
}

.msCell.isOpen {
  background: var(--ms-mid);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.18);
  cursor: default;
}

.msCell.isFlag {
  color: #ef4444;
}

.msCell.isMine {
  background: #ff4d4d;
}

.msCell.isHint {
  background: #ff3b3b;
  color: #fff;
  animation: msBlink 360ms ease-in-out infinite;
}

@keyframes msBlink {
  0% { filter: brightness(1); }
  50% { filter: brightness(1.35); }
  100% { filter: brightness(1); }
}

.n1 { color: #2563eb; }
.n2 { color: #16a34a; }
.n3 { color: #dc2626; }
.n4 { color: #1e3a8a; }
.n5 { color: #7f1d1d; }
.n6 { color: #0f766e; }
.n7 { color: #111827; }
.n8 { color: #6b7280; }

.msBottom {
  margin-top: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.msOps {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.msDiff {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.msDiffLabel {
  font-size: 12px;
  font-weight: 1000;
  color: rgba(100, 116, 139, 0.95);
}
.msDiffBtn.isOn {
  border-color: rgba(37, 99, 235, 0.25);
  background: rgba(37, 99, 235, 0.10);
  color: rgba(37, 99, 235, 0.95);
}
.msHint {
  font-size: 12px;
  font-weight: 900;
  color: rgba(100, 116, 139, 0.95);
}

@media (max-width: 420px) {
  /* 手机端仍然由 JS 决定 cell，避免因为固定值导致不满屏 */
  .msCounter {
    font-size: 20px;
    padding: 6px 8px;
  }
}
