.m2-game {
  display: grid;
  gap: 12px;
}

.m2-head {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.m2-meter {
  min-width: 0;
  border: 1px solid #d5dde8;
  border-radius: 8px;
  padding: 9px 10px;
  background: #ffffff;
}

.m2-meter span {
  display: block;
  color: #667085;
  font-size: 12px;
  line-height: 1.2;
}

.m2-meter strong {
  display: block;
  margin-top: 3px;
  color: #17202a;
  font-size: 15px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.m2-status {
  min-height: 48px;
  border: 1px solid #d5dde8;
  border-radius: 8px;
  padding: 10px 12px;
  background: #ffffff;
  color: #344054;
  font-size: 14px;
  line-height: 1.45;
}

.m2-status.m2-warn {
  border-color: #b45309;
  background: #fff7ed;
  color: #8a3b07;
}

.m2-status.m2-done {
  border-color: #147d4f;
  background: #e7f6ef;
  color: #0f5132;
}

.m2-board {
  display: grid;
  gap: 9px;
  overflow: hidden;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 12px;
  background:
    linear-gradient(180deg, #f8fafc, #eef4f8),
    repeating-linear-gradient(90deg, rgba(21, 38, 61, 0.04) 0, rgba(21, 38, 61, 0.04) 1px, transparent 1px, transparent 20px);
}

.m2-guide {
  min-height: 24px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: #475467;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
}

.m2-guide-left,
.m2-guide-down {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
}

.m2-matrix {
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 5px;
}

.m2-cell {
  position: relative;
  isolation: isolate;
  min-width: 0;
  min-height: 44px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
  color: #17202a;
  box-shadow: inset 0 -1px 0 rgba(20, 31, 42, 0.05);
}

.m2-value {
  position: relative;
  z-index: 2;
  font-size: 16px;
  font-weight: 850;
  line-height: 1;
}

.m2-cell.m2-visited {
  border-color: #8aa4c3;
  background: #f5f9ff;
}

.m2-cell.m2-eliminated {
  border-color: #d8dee8;
  background: #eef2f6;
  color: #8a94a3;
}

.m2-cell.m2-eliminated::after {
  content: "";
  position: absolute;
  z-index: 1;
  left: -16%;
  right: -16%;
  top: 50%;
  height: 2px;
  border-radius: 2px;
  background: #667085;
  transform: rotate(-27deg);
  opacity: 0.8;
}

.m2-cell.m2-col-cut::before {
  content: "";
  position: absolute;
  z-index: 0;
  top: -20%;
  bottom: -20%;
  left: 50%;
  width: 10px;
  background: rgba(100, 116, 139, 0.12);
  transform: translateX(-50%);
}

.m2-cell.m2-row-cut::before {
  content: "";
  position: absolute;
  z-index: 0;
  left: -20%;
  right: -20%;
  top: 50%;
  height: 10px;
  background: rgba(100, 116, 139, 0.12);
  transform: translateY(-50%);
}

.m2-cell.m2-last-cut {
  border-color: #b45309;
  background: #fff7ed;
}

.m2-cell.m2-current-cell {
  z-index: 3;
  border-color: #0f766e;
  background: #d7f4ef;
  color: #0f3f3b;
  box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.22), 0 8px 18px rgba(15, 118, 110, 0.16);
}

.m2-cell.m2-current-cell::before {
  content: "";
  position: absolute;
  top: 5px;
  right: 5px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #0f766e;
}

.m2-cell.m2-found-cell {
  z-index: 4;
  border-color: #147d4f;
  background: #e7f6ef;
  color: #0f5132;
  box-shadow: 0 0 0 3px rgba(20, 125, 79, 0.2), 0 9px 20px rgba(20, 125, 79, 0.16);
}

.m2-cell.m2-found-cell::before {
  content: "";
  position: absolute;
  inset: 5px;
  z-index: 1;
  border: 2px solid rgba(20, 125, 79, 0.55);
  border-radius: 6px;
}

.m2-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.m2-dir {
  min-width: 0;
  min-height: 64px;
  border: 1px solid #b9c5d5;
  border-radius: 8px;
  background: #ffffff;
  color: #17202a;
  cursor: pointer;
  touch-action: manipulation;
  box-shadow: 0 8px 18px rgba(22, 34, 51, 0.08);
}

.m2-dir span {
  display: block;
  font-size: 34px;
  font-weight: 900;
  line-height: 1;
}

.m2-dir:active {
  transform: translateY(1px);
  box-shadow: 0 4px 12px rgba(22, 34, 51, 0.1);
}

.m2-dir:focus-visible,
.m2-btn:focus-visible {
  outline: 3px solid rgba(15, 118, 110, 0.26);
  outline-offset: 2px;
}

.m2-dir.m2-wrong {
  border-color: #b42318;
  background: #fff1f0;
  color: #b42318;
  animation: m2-shake 0.32s ease-in-out;
}

.m2-dir:disabled,
.m2-btn:disabled {
  cursor: default;
  opacity: 0.62;
  box-shadow: none;
}

.m2-trace {
  min-height: 42px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
  border: 1px dashed #aeb8c7;
  border-radius: 8px;
  padding: 8px;
  background: #fbfcfe;
}

.m2-chip,
.m2-empty {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 12px;
  line-height: 1.2;
}

.m2-chip {
  border: 1px solid #d5dde8;
  background: #ffffff;
  color: #344054;
  font-weight: 700;
}

.m2-chip strong {
  color: #0f766e;
}

.m2-empty {
  color: #667085;
}

.m2-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.m2-btn {
  min-width: 0;
  min-height: 44px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 9px 10px;
  background: #ffffff;
  color: #17202a;
  font-size: 14px;
  font-weight: 750;
  cursor: pointer;
  touch-action: manipulation;
}

.m2-btn.m2-primary {
  border-color: #0f766e;
  background: #0f766e;
  color: #ffffff;
}

@keyframes m2-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

@media (max-width: 520px) {
  .m2-head {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .m2-meter:last-child {
    grid-column: 1 / -1;
  }

  .m2-board {
    padding: 10px;
  }

  .m2-matrix {
    gap: 4px;
  }

  .m2-value {
    font-size: 15px;
  }

  .m2-dir {
    min-height: 58px;
  }
}

@media (max-width: 380px) {
  .m2-cell {
    min-height: 44px;
  }

  .m2-value {
    font-size: 14px;
  }

  .m2-status {
    font-size: 13px;
  }
}
