:root {
  --ms-bar: #3f4a3c;
  --ms-menu: #2a3228;
  --ms-text: #1c1917;
  --ms-accent: #b45309;
  --ms-link: #0f766e;
  --ms-cell: #8b9680;
  --ms-cell-open: #d7ddd0;
  --ms-bg: #c8d0c2;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  min-height: 100%;
  font-family: "Segoe UI", "Trebuchet MS", sans-serif;
  color: var(--ms-text);
  background:
    radial-gradient(ellipse at top, #e7ebe4 0%, #d5dcd0 45%, var(--ms-bg) 100%);
}

.ms-chrome {
  background: var(--ms-bar);
  color: #f8fafc;
  padding: 0.75rem 1rem 1.25rem;
  text-align: center;
}

.ms-chrome__brand {
  max-width: 64rem;
  margin: 0 auto;
}

.ms-chrome__logo {
  display: inline-block;
  line-height: 0;
}

.ms-chrome__logo img,
.banner-logo {
  display: block;
  max-width: min(100%, 42rem);
  max-height: 8rem;
  width: auto;
  height: auto;
  margin: 0 auto 1rem;
}

.ms-chrome__links {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

.ms-chrome__links a {
  color: #5eead4;
  font-weight: 600;
  text-decoration: none;
}

.ms-chrome__links a:hover {
  color: #99f6e4;
}

.ms-main {
  max-width: 64rem;
  margin: 0 auto;
  padding: 0.75rem 1rem 2rem;
}

.ms-toolbar {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-bottom: 0.85rem;
}

.ms-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  align-items: center;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.ms-modes {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.ms-mode {
  appearance: none;
  border: 2px solid #3f4a3c;
  background: #f5f5f4;
  color: var(--ms-text);
  font-weight: 700;
  padding: 0.55rem 0.9rem;
  border-radius: 6px;
  cursor: pointer;
  min-width: 4.5rem;
}

.ms-mode.is-active {
  background: var(--ms-accent);
  border-color: var(--ms-accent);
  color: #fff;
}

.ms-pause-btn {
  appearance: none;
  border: 2px solid #3f4a3c;
  background: #f5f5f4;
  color: var(--ms-text);
  font-weight: 700;
  padding: 0.55rem 0.9rem;
  border-radius: 6px;
  cursor: pointer;
  min-width: 4.5rem;
}

.ms-pause-btn[aria-pressed="true"] {
  background: var(--ms-accent);
  border-color: var(--ms-accent);
  color: #fff;
}

.ms-pause-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.ms-opening-wrap {
  display: flex;
}

.ms-opening-wrap[hidden] {
  display: none;
}

.ms-opening-btn {
  appearance: none;
  border: 2px solid var(--ms-accent);
  background: var(--ms-accent);
  color: #fff;
  font-weight: 700;
  padding: 0.55rem 0.9rem;
  border-radius: 6px;
  cursor: pointer;
}

.ms-opening-btn:hover {
  filter: brightness(1.05);
}

.ms-status {
  min-height: 1.4rem;
  font-weight: 600;
}

.ms-status.is-mine {
  color: #b91c1c;
}

.ms-status.is-win {
  color: #0f766e;
}

.ms-board-wrap {
  position: relative;
  overflow: auto;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 0.5rem;
}

.ms-pause-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(200, 208, 194, 0.94);
  border-radius: 8px;
  pointer-events: auto;
}

.ms-pause-overlay[hidden] {
  display: none;
}

.ms-pause-overlay__label {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ms-text);
}

.ms-board-wrap.is-paused .ms-board {
  pointer-events: none;
}

.ms-board-wrap.is-paused .ms-cell {
  background: linear-gradient(160deg, #9aa58e, var(--ms-cell));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25);
  color: transparent;
  cursor: default;
}

.ms-board-wrap.is-paused .ms-cell::after {
  content: none;
}

.ms-board {
  display: grid;
  gap: 2px;
  width: max-content;
  max-width: 100%;
  margin: 0 auto;
  background: #2a3228;
  padding: 4px;
  border-radius: 8px;
  touch-action: none;
  user-select: none;
}

.ms-cell {
  appearance: none;
  border: none;
  margin: 0;
  padding: 0;
  aspect-ratio: 1;
  width: clamp(1.15rem, 4.2vw, 2rem);
  min-width: 1.15rem;
  background: linear-gradient(160deg, #9aa58e, var(--ms-cell));
  color: var(--ms-text);
  font-weight: 800;
  font-size: clamp(0.65rem, 2.4vw, 0.95rem);
  border-radius: 3px;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.ms-cell.is-open {
  background: var(--ms-cell-open);
  box-shadow: none;
  cursor: default;
}

.ms-cell.is-mine {
  background: #7f1d1d;
  color: #fecaca;
}

.ms-cell.is-mine-safe {
  background: #166534;
  color: #bbf7d0;
}

.ms-cell.is-flag::after {
  content: "⚑";
  color: #b45309;
}

.ms-cell.is-maybe::after {
  content: "?";
  color: #0f766e;
  font-weight: 900;
}

.ms-cell[data-n="1"] { color: #1d4ed8; }
.ms-cell[data-n="2"] { color: #15803d; }
.ms-cell[data-n="3"] { color: #b91c1c; }
.ms-cell[data-n="4"] { color: #1e3a8a; }
.ms-cell[data-n="5"] { color: #7c2d12; }
.ms-cell[data-n="6"] { color: #0f766e; }
.ms-cell[data-n="7"] { color: #111827; }
.ms-cell[data-n="8"] { color: #57534e; }

.ms-help {
  margin: 0.75rem 0 0;
  font-size: 0.9rem;
  opacity: 0.85;
}

.ms-modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(42, 50, 40, 0.55);
}

.ms-modal[hidden] {
  display: none;
}

.ms-modal__panel {
  width: min(100%, 22rem);
  background: #f5f5f4;
  color: var(--ms-text);
  border-radius: 10px;
  border: 2px solid var(--ms-bar);
  box-shadow: 0 12px 32px rgba(28, 25, 23, 0.28);
  padding: 1.1rem 1.15rem 1rem;
}

.ms-modal__title {
  margin: 0 0 0.5rem;
  font-size: 1.15rem;
}

.ms-modal__body {
  margin: 0 0 1rem;
  line-height: 1.45;
}

.ms-modal__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
}

.ms-modal__btn {
  appearance: none;
  border: 2px solid #3f4a3c;
  background: #f5f5f4;
  color: var(--ms-text);
  font-weight: 700;
  padding: 0.5rem 0.85rem;
  border-radius: 6px;
  cursor: pointer;
}

.ms-modal__btn--primary {
  background: var(--ms-accent);
  border-color: var(--ms-accent);
  color: #fff;
}

.ms-modal__btn:hover {
  filter: brightness(1.05);
}

@media (max-width: 600px) {
  .ms-chrome__logo img,
  .banner-logo {
    max-height: 5rem;
  }
}

@media (min-width: 720px) {
  .ms-cell {
    width: clamp(1.4rem, 2.6vw, 2.15rem);
  }
}
