:root {
  --minisweeper-blue: rgb(0, 122, 255);
  --minisweeper-cell-size: 26px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  padding: 66px 12px 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
}
#container {
  display: flow-root;
  width: min(calc(100vw - 24px), max(240px, var(--board-width, 240px)));
}
h1 { font-size: 24px; }
p { font-size: 16px; font-weight: normal; }
#container > h1, #container > p { text-align: center; }
a, a:link, a:visited, a:active { color: var(--minisweeper-blue); font-weight: 600; }
a:focus, a:hover { color: rgb(36, 172, 255) !important; text-decoration: none !important; }
.player-embed #container > h1,
.player-embed #container > p { display: none; }
.player-embed body { padding-top: 50px; padding-bottom: 10px; }

#minisweeper-menu {
  position: fixed;
  z-index: 10;
  top: 0;
  left: 0;
  right: 0;
  height: 42px;
  padding: 4px max(12px, calc((100vw - 1100px) / 2));
  border-bottom: 1px solid #e5e5e5;
  background: #fff;
}
#minisweeper-menu button,
.minisweeper-dialog button {
  font: inherit;
  color: var(--minisweeper-blue);
  background: transparent;
  border: 0;
  cursor: pointer;
}
#minisweeper-menu-button { padding: 4px 10px; font-weight: 600 !important; }
#minisweeper-menu-items {
  position: absolute;
  top: 38px;
  min-width: 180px;
  padding: 5px;
  border: 1px solid #ddd;
  border-radius: 5px;
  background: #fff;
  box-shadow: 0 6px 20px #0002;
}
#minisweeper-menu-items[hidden], .minisweeper-modal[hidden], [hidden] { display: none !important; }
#minisweeper-menu-items button {
  display: block;
  width: 100%;
  padding: 7px 10px;
  text-align: left;
  border-radius: 3px;
}
#minisweeper-menu-items button:hover,
#minisweeper-menu-items button:focus-visible { background: #f0f5ff; }

.minisweeper-board-scroll { max-width: 100%; overflow-x: auto; }
#minisweeper-board { width: calc(var(--columns) * var(--minisweeper-cell-size)); }
.minisweeper-header {
  height: clamp(28px, calc(var(--minisweeper-cell-size) * 1.7), 44px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 5px;
  background: #f0f0f0;
  border: 1px solid #dedede;
  border-bottom: 0;
}
.minisweeper-counter {
  min-width: clamp(32px, calc(var(--minisweeper-cell-size) * 2.1), 55px);
  font-size: clamp(10px, calc(var(--minisweeper-cell-size) * .62), 16px);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
#minisweeper-timer { text-align: right; }
.minisweeper-face {
  border: 0;
  background: transparent;
  padding: 1px 3px;
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
  font-size: clamp(16px, calc(var(--minisweeper-cell-size) * .9), 23px);
  line-height: 1;
  cursor: pointer;
}
.minisweeper-row { display: flex; height: var(--minisweeper-cell-size); }
.minisweeper-cell {
  flex: 0 0 var(--minisweeper-cell-size);
  width: var(--minisweeper-cell-size);
  height: var(--minisweeper-cell-size);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #f0f0f0;
  border: clamp(1px, calc(var(--minisweeper-cell-size) * .08), 2px) solid #f0f0f0;
  font-size: clamp(6px, calc(var(--minisweeper-cell-size) * .62), 16px);
  line-height: 1;
}
.minisweeper-unrevealed {
  border: clamp(1px, calc(var(--minisweeper-cell-size) * .08), 2px) outset #ececec;
  background: #c0c0c0;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}
.minisweeper-unrevealed:focus-visible,
.minisweeper-face:focus-visible,
#minisweeper-menu button:focus-visible,
.minisweeper-dialog button:focus-visible {
  outline: 2px solid var(--minisweeper-blue);
  outline-offset: -2px;
}
#minisweeper-controls { padding-top: 12px; }
#minisweeper-controls > div {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 6px;
}

.minisweeper-stats {
  width: min(100%, 360px);
  margin: 0 auto;
  line-height: 1.25;
}
.minisweeper-stats h2 { margin: 0 0 6px; font-size: 18px; }
.minisweeper-stats table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.minisweeper-stats th,
.minisweeper-stats td {
  padding: 4px 3px;
  border-bottom: 1px solid #eee;
  white-space: nowrap;
}
.minisweeper-stats th:first-child { text-align: left; }
.minisweeper-stats th:not(:first-child),
.minisweeper-stats td { text-align: right; }
.minisweeper-stats-back {
  display: block;
  margin-top: 9px;
  text-align: center;
}

.minisweeper-modal {
  position: fixed;
  z-index: 20;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: #0005;
}
.minisweeper-dialog {
  width: min(100%, 330px);
  padding: 20px;
  border: 1px solid #dedede;
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 12px 32px #0002;
}
.minisweeper-dialog h2 { margin: 0 0 12px; font-size: 19px; }
.minisweeper-dialog h3 { margin: 0 0 7px; font-size: 16px; }
.minisweeper-dialog p { margin: 0 0 16px; }
.minisweeper-dialog form label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 10px 0;
}
.minisweeper-dialog input {
  width: 90px;
  padding: 5px 6px;
  font: inherit;
  border: 1px solid #ccc;
  border-radius: 3px;
}
.minisweeper-comparison {
  margin: 0 0 14px;
  padding: 10px 12px;
  border-radius: 5px;
  background: #f0f5ff;
}
.minisweeper-comparison p { margin: 0 0 6px; }
.minisweeper-comparison p:last-child { margin-bottom: 0; }
.minisweeper-challenge-stats { margin: 0; }
.minisweeper-challenge-stats > div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 5px 0;
  border-bottom: 1px solid #eee;
}
.minisweeper-challenge-stats dt { color: #555; }
.minisweeper-challenge-stats dd { margin: 0; text-align: right; font-weight: 600; }
.minisweeper-share-button {
  display: inline-flex;
  align-items: center;
  padding: 5px 8px;
}
#minisweeper-custom-error { color: #b42318; font-size: 14px; }
.minisweeper-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 18px;
}
.minisweeper-dialog-actions-centered { justify-content: center; }
.minisweeper-dialog-actions button { padding: 5px 8px; font-weight: 600 !important; }
