/* Classic Minesweeper for the XP desktop. All selectors are scoped to .ms-app
   so the game cannot affect the CV window. */

:root {
  --ms-mine-icon: url("data:image/svg+xml,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22%20viewBox=%220%200%2032%2032%22%3E%3Cg%20stroke=%22%23000%22%20stroke-width=%222%22%20stroke-linecap=%22round%22%3E%3Cpath%20d=%22M16%203v26M3%2016h26M6.8%206.8l18.4%2018.4M25.2%206.8%206.8%2025.2%22/%3E%3C/g%3E%3Ccircle%20cx=%2216%22%20cy=%2216%22%20r=%228%22%20fill=%22%23000%22/%3E%3Ccircle%20cx=%2213%22%20cy=%2213%22%20r=%222%22%20fill=%22%23fff%22/%3E%3C/svg%3E");
  --ms-flag-icon: url("data:image/svg+xml,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22%20viewBox=%220%200%2024%2024%22%3E%3Cpath%20d=%22M11%203v17%22%20stroke=%22%23000%22%20stroke-width=%222%22/%3E%3Cpath%20d=%22M11%204h8l-3%204%203%204h-8z%22%20fill=%22%23d40000%22/%3E%3Cpath%20d=%22M6%2021h12%22%20stroke=%22%23000%22%20stroke-width=%223%22%20stroke-linecap=%22round%22/%3E%3Cpath%20d=%22M9%2018h5%22%20stroke=%22%23000%22%20stroke-width=%222%22/%3E%3C/svg%3E");
}

.ms-app {
  --ms-cell: 16px;
  position: relative;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  width: 100%;
  background: #c0c0c0;
  color: #000;
  font: 12px/1.2 Tahoma, "MS Sans Serif", Verdana, Arial, sans-serif;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.ms-app button { font: inherit; }

.ms-menubar {
  position: relative;
  z-index: 20;
  flex: none;
  display: flex;
  gap: 1px;
  padding: 2px 4px;
  border-bottom: 1px solid #aca899;
  background: #ece9d8;
}

.ms-menu { position: relative; }

.ms-menu-button {
  padding: 2px 7px;
  border: 0;
  background: transparent;
  color: #000;
  cursor: default;
}
.ms-menu-button:hover,
.ms-menu.open > .ms-menu-button {
  background: #316ac5;
  color: #fff;
}

.ms-menu-list {
  position: absolute;
  top: 100%;
  left: 0;
  display: none;
  min-width: 178px;
  padding: 2px;
  border: 1px solid #aca899;
  background: #fff;
  box-shadow: 2px 2px 3px rgba(0, 0, 0, .25);
  z-index: 30;
}
.ms-menu.open > .ms-menu-list { display: block; }

.ms-menu-item {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 23px;
  padding: 3px 20px 3px 22px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #000;
  text-align: left;
  white-space: nowrap;
  cursor: default;
}
.ms-menu-item:hover,
.ms-menu-item:focus-visible {
  background: #316ac5;
  color: #fff;
  outline: none;
}
.ms-check {
  position: absolute;
  left: 6px;
  width: 12px;
  text-align: center;
}
.ms-shortcut {
  margin-left: auto;
  padding-left: 22px;
  color: #696969;
}
.ms-menu-item:hover .ms-shortcut,
.ms-menu-item:focus-visible .ms-shortcut { color: #fff; }
.ms-sep {
  height: 0;
  margin: 3px 4px;
  border-top: 1px solid #aca899;
}

.ms-frame {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  padding: 8px;
  overflow: auto;
}

.ms-game {
  flex: none;
  margin: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ms-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 6px;
  border: 2px solid;
  border-color: #808080 #fff #fff #808080;
  background: #c0c0c0;
}

.ms-counter {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 43px;
  height: 27px;
  padding: 0 2px;
  border: 2px solid;
  border-color: #808080 #fff #fff #808080;
  background: #000;
  color: #f00;
  font: bold 19px/1 "Courier New", Courier, monospace;
  letter-spacing: 1px;
  text-shadow: 0 0 2px #f00;
}

.ms-face {
  flex: none;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 2px solid;
  border-color: #fff #808080 #808080 #fff;
  background: #c0c0c0;
  cursor: pointer;
}
.ms-face:hover { background: #d0d0d0; }
.ms-face:active {
  border-color: #808080 #fff #fff #808080;
}
.ms-face:focus-visible {
  outline: 2px solid #316ac5;
  outline-offset: 1px;
}
.ms-face svg {
  display: block;
  width: 24px;
  height: 24px;
}

.ms-board-wrap {
  padding: 2px;
  border: 3px solid;
  border-color: #808080 #fff #fff #808080;
  background: #c0c0c0;
}

.ms-board {
  display: grid;
  grid-template-columns: repeat(var(--ms-cols, 9), var(--ms-cell, 16px));
  grid-auto-rows: var(--ms-cell, 16px);
  outline: none;
  background: #808080;
}
.ms-board:focus-visible {
  outline: 2px solid #316ac5;
  outline-offset: 2px;
}

.ms-cell {
  position: relative;
  display: grid;
  place-items: center;
  width: var(--ms-cell, 16px);
  height: var(--ms-cell, 16px);
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 2px solid;
  border-color: #fff #808080 #808080 #fff;
  border-radius: 0;
  background: #c0c0c0;
  color: #000;
  font: bold calc(var(--ms-cell, 16px) * .62) / 1 Tahoma, "MS Sans Serif", Verdana, sans-serif;
  cursor: default;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.ms-cell.revealed {
  border: 1px solid #b8b8b8;
  background: #c0c0c0;
}

.ms-cell.mine {
  background-image: var(--ms-mine-icon);
  background-repeat: no-repeat;
  background-position: center;
  background-size: 72%;
}

.ms-cell.flag {
  background-image: var(--ms-flag-icon);
  background-repeat: no-repeat;
  background-position: center;
  background-size: 72%;
}

.ms-cell.exploded { background-color: #f00; }
.ms-cell.question { color: #0000d0; }
.ms-cell[data-num="1"] { color: #0000ff; }
.ms-cell[data-num="2"] { color: #008000; }
.ms-cell[data-num="3"] { color: #ff0000; }
.ms-cell[data-num="4"] { color: #000080; }
.ms-cell[data-num="5"] { color: #800000; }
.ms-cell[data-num="6"] { color: #008080; }
.ms-cell[data-num="7"] { color: #000000; }
.ms-cell[data-num="8"] { color: #808080; }

.ms-cell.focused {
  outline: 2px solid #316ac5;
  outline-offset: -2px;
  z-index: 1;
}

.ms-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.ms-modal {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  background: rgba(0, 0, 0, .18);
}
.ms-modal[hidden] { display: none; }

.ms-dialog {
  width: min(340px, 100%);
  max-height: 100%;
  display: flex;
  flex-direction: column;
  border: 1px solid #0a3c9a;
  border-radius: 4px;
  background: #ece9d8;
  box-shadow: 2px 4px 12px rgba(0, 0, 0, .35);
  overflow: hidden;
}
.ms-dialog-head {
  display: flex;
  align-items: center;
  padding: 4px 6px 4px 9px;
  background: linear-gradient(180deg, #3a91ed 0%, #176ed3 35%, #0960c7 72%, #287cdf 100%);
  color: #fff;
  font-weight: bold;
  text-shadow: 1px 1px 2px #123c83;
}
.ms-dialog-title { flex: 1; }
.ms-dialog-x {
  width: 22px;
  height: 20px;
  padding: 0;
  border: 1px solid #fff;
  border-radius: 3px;
  background: linear-gradient(#f49a80, #dc351e 55%, #ad180b);
  color: #fff;
  font-weight: bold;
  cursor: pointer;
}
.ms-dialog-body {
  padding: 12px;
  overflow: auto;
  color: #172b3e;
}
.ms-dialog-body p { margin: 0 0 8px; }
.ms-dialog-body p:last-child { margin-bottom: 0; }
.ms-dialog-body ul { margin: 4px 0 8px; padding-left: 18px; }
.ms-dialog-body li { margin: 3px 0; }
.ms-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 8px 10px;
  border-top: 1px solid #c1d4e8;
  background: linear-gradient(#eaf3fb, #cbddef);
}
.ms-dialog-actions button {
  min-width: 72px;
  padding: 4px 12px;
  border: 1px solid #abc0d6;
  border-radius: 3px;
  background: linear-gradient(#fff, #d9e5f0);
  color: #213e59;
  cursor: pointer;
}
.ms-dialog-actions button:hover { border-color: #4b91d3; }
.ms-dialog-actions button.primary {
  border-color: #4b91d3;
  background: linear-gradient(#fff, #c5ddf3);
  font-weight: bold;
}

.ms-form { display: grid; gap: 8px; }
.ms-form label { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.ms-form input {
  width: 92px;
  padding: 2px 4px;
  border: 1px solid #7f9db9;
  background: #fff;
  font: inherit;
}
.ms-form-error { margin: 0; color: #b00000; }
.ms-hint { color: #53677b; font-size: 11px; }

.ms-loading,
.ms-error {
  margin: 0;
  padding: 24px 12px;
  color: #172b3e;
  text-align: center;
}
.mines-body > .ms-loading,
.mines-body > .ms-error { margin: auto; }
.ms-error { color: #b00000; max-width: 460px; }

@media (max-width: 650px) {
  .ms-app { font-size: 13px; }
  .ms-menubar { padding: 2px 2px; }
  .ms-menu-button { padding: 5px 9px; }
  .ms-frame { padding: 4px; }
  .ms-panel { padding: 5px 7px; }
  .ms-counter { min-width: 50px; height: 32px; font-size: 22px; }
  .ms-face { width: 38px; height: 38px; }
  .ms-face svg { width: 28px; height: 28px; }
  .ms-dialog-body { padding: 10px; }
}
