.ms-shell {
  padding: 1.3rem;
  margin: 1.5rem auto;
  display: flex;
  flex-direction: column;
  gap: 1.8rem;
  width: min(96vw, 1400px);
}

.ms-hero {
  margin-bottom: 0.4rem;
}

.ms-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.45rem;
}

.ms-top__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 1rem;
  align-items: start;
}

.ms-start {
  padding: 1.1rem;
  border-radius: 18px;
  border: 1px solid var(--glass-border);
  background: linear-gradient(140deg, rgba(62, 222, 255, 0.08), rgba(255, 255, 255, 0.05));
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.ms-start__head {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.ms-info {
  padding: 1rem;
  border-radius: 18px;
  border: 1px solid var(--glass-border);
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.06), rgba(62, 222, 255, 0.08));
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 400px;
}

.ms-info h4 {
  margin-bottom: 0.2rem;
}

.ms-hero__stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.5rem;
}

.ms-hero__actions {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.ms-config {
  padding: 0.6rem 0.7rem;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.ms-config__row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.ms-config__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.5rem;
  align-items: end;
}

.ms-config .glass-input {
  margin-top: 0.1rem;
}

.ms-mode-switch,
.ms-action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.ms-action-row .glass-button,
.ms-config .glass-button {
  min-width: 96px;
  white-space: nowrap;
  padding-inline: 1rem;
}

.ms-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.2rem;
  margin-top: 0.2rem;
  margin-bottom: 50px;
}

.ms-board {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: 100%;
}

.ms-board__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.ms-board__title {
  font-size: 1.15rem;
}

.ms-board__meta {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  padding: 0.45rem 0.65rem;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.05);
  font-weight: 700;
}

.ms-topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.6rem;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
}

.ms-counter {
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  padding: 0.35rem 0.6rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-weight: 800;
}

.ms-counter .label {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.ms-face {
  width: 54px;
  height: 54px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.09), rgba(255, 255, 255, 0.03));
  font-size: 24px;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform 100ms ease, box-shadow 120ms ease;
}

.ms-face:active {
  transform: translateY(1px);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.2);
}

.ms-grid {
  --cols: 10;
  --cell-size: 40px;
  display: grid;
  grid-template-columns: repeat(var(--cols), var(--cell-size));
  justify-content: center;
  margin: 0.5rem auto 0.9rem;
  gap: 2px;
  background: #bdbdbd;
  border: 1px solid #8f8f8f;
  padding: 0.55rem;
  border-radius: 12px;
  box-shadow: inset 0 0 0 1px #dcdcdc;
}

.ms-cell {
  position: relative;
  height: var(--cell-size);
  width: var(--cell-size);
  display: grid;
  place-items: center;
  border-radius: 6px;
  border: 1px solid #8f8f8f;
  background: linear-gradient(180deg, #e7e7e7, #c1c1c1);
  box-shadow: inset -2px -2px 0 #f3f3f3, inset 2px 2px 0 #7d7d7d;
  cursor: pointer;
  color: #111;
  font-weight: 800;
  font-size: clamp(0.9rem, calc(var(--cell-size) * 0.36), 1.6rem);
  line-height: 1;
  white-space: nowrap;
  transition: transform 80ms ease, box-shadow 80ms ease, background 80ms ease, border-color 80ms ease;
  user-select: none;
}

.ms-cell[data-state="hidden"] {
  background: linear-gradient(160deg, #f5f5f5 0%, #c7c7c7 50%, #8b8b8b 100%);
  border-color: #5d5d5d;
  box-shadow: inset -3px -3px 0 #ffffff, inset 3px 3px 0 #3f3f3f, 0 3px 8px rgba(0, 0, 0, 0.24);
}

.ms-cell:hover {
  transform: translateY(-1px);
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.15), inset -2px -2px 0 #f3f3f3, inset 2px 2px 0 #7d7d7d;
}

.ms-cell.revealed:hover {
  transform: none;
  box-shadow: inset 2px 2px 0 #7d7d7d, inset -2px -2px 0 #e4e4e4;
}

.ms-cell[data-state="hidden"]:active {
  transform: translateY(1px);
  box-shadow: inset 1px 1px 0 #7d7d7d, inset -1px -1px 0 #f3f3f3;
}

.ms-cell.revealed {
  background: #ececec;
  color: #111;
  box-shadow: inset 1px 1px 0 #b8b8b8, inset -2px -2px 0 #f8f8f8;
  border-color: #bcbcbc;
  transform: translateY(0);
}

.ms-cell.triggered {
  background: #ffb3b3;
  border-color: #ff7878;
}

.ms-cell.wrong-flag {
  color: #a00;
  background: #ffe1e1;
}

.ms-cell.revealed[data-number="0"],
.ms-cell.empty {
  color: #555;
  background: #cfcfcf;
}

.ms-cell.flag {
  color: #d00000;
}

.ms-cell.mine {
  background: #c0c0c0;
  color: #000;
}

.ms-cell__ping {
  position: absolute;
  inset: 4px;
  border-radius: 8px;
  border: 1px solid rgba(0, 110, 255, 0.6);
  opacity: 0;
  animation: msPing 1s ease forwards;
}

@keyframes msPing {
  from {
    opacity: 0.95;
    transform: scale(0.9);
  }
  to {
    opacity: 0;
    transform: scale(1.2);
  }
}

.ms-status {
  padding: 0.65rem 0.8rem;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-weight: 700;
}

.ms-side {
  padding: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.ms-card {
  padding: 0.75rem 0.8rem;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.ms-rule-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.ms-log {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  max-height: 220px;
  overflow: auto;
}

.ms-log-wrap {
  display: grid;
  grid-template-columns: 1fr;
}

.ms-log-card {
  padding: 0.9rem 1rem;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.ms-log__item {
  padding: 0.4rem 0.55rem;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px dashed rgba(255, 255, 255, 0.08);
  font-size: 0.95rem;
}

.ms-n1 {
  color: #0b24fb;
}
.ms-n2 {
  color: #0f8a1f;
}
.ms-n3 {
  color: #e00000;
}
.ms-n4 {
  color: #000080;
}
.ms-n5 {
  color: #800000;
}
.ms-n6 {
  color: #008080;
}
.ms-n7 {
  color: #000000;
}
.ms-n8 {
  color: #555555;
}

@media (max-width: 1024px) {
  .ms-hero {
    grid-template-columns: 1fr;
  }
  .ms-layout {
    grid-template-columns: 1fr;
  }
  .ms-config__grid {
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  }
  .ms-grid {
    grid-template-columns: repeat(var(--cols), var(--cell-size));
    gap: 2px;
  }
  .ms-cell {
    height: var(--cell-size);
    width: var(--cell-size);
  }
}
